I want to add ads to my project but when i add the line below, it doesn't work:
implementation 'com.google.android.gms:play-services-ads:18.1.0'
these are the dependencies from the build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
It is likely, that you might not have added the Google Services Gradle Plugin to the project, as well as the google-services.json file (which can be downloaded from the Firebase console) - and so your application fails to authenticate.
Adding the com.google.android.gms.ads.APPLICATION_ID into the AndroidManifest.xml has the same effect, because the Play Services plugin adds the values from google-services.json at build-time.
... when only using AdMob, the second option should be preferred.
Do you have inside top-level build.gradle file reference to the google() repo or to maven { url "https://maven.google.com" }? Do you have some specific error inside log?
Try to create a new project and copy old project files and paste in a new one. If it should help!
Related
I have the following in my app build gradle:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "com.mapbox.navigation:ui:1.4.0"
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.11.0'}
and have successfully run things such as a map and placing markers down etc. However, when I go to import anything from services, such as import com.mapbox.services.android.navigation.ui.v5.NavigationLauncher; Android Studio cannot find anything. I've tried different versions in case the imports I needed were deprecated but to no avail. Any ideas? All the tutorials and example code in the documentation and third-party all use these imports and I don't really see a way around them.
Thanks!
In the module-level build.gradle file, add the following dependencies:
// in addition to the rest of your build.gradle contents
// you should include the following repository and dependencies
repositories {
mavenCentral()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6'
}
I have seen this problem going round and I have tried downgrading the Google App Id and even tried upgrading it but nothing worked. I even checked for updates but still no luck. I am having this error where it is saying 'Missing Google App Id' when I have it implemented. Can someone help?
This is from the build.gradle(WeightTracker)
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
This is from build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-storage'
implementation platform('com.google.firebase:firebase-bom:25.4.1')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
This is the error I keep getting:
Missing Google App Id. Please follow instructions on https://firebase.google.com/ to get a valid config file that contains a Google App Id
Im getting the error
The following classes could not be found:
- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
- android.support.design.widget.NavigationView (Fix Build Path, Edit XML, Create Class)
- android.support.v4.widget.DrawerLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project.
Heres my module app:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
I've tried to rebuild, clean and change the implementations but nothings seems to work
Does anyone know how I could fix this?? it started when I updated android studio and created a new project.
Your dependency is mixed of support library and AndroidX which is not right. Refactor it to AndroidX using Android Studio.
Refactor > Migrate to AndroidX and press Do Refactor
You have to use
androidx.coordinatorlayout.widget.CoordinatorLayout
com.google.android.material.navigation.NavigationView
androidx.drawerlayout.widget.DrawerLayout
instead of
android.support.design.widget.CoordinatorLayout
android.support.design.widget.NavigationView
android.support.v4.widget.DrawerLayout
Hi I am developing a sdk, and when I add these SDK into a app proyect I get the following error:
Manifest merger failed : Attribute application#appComponentFactory
value=(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:22:5-125:19 to override.
The build.gradle are the followings
App build.gradle
dependencies {
implementation project(':sdkA')
implementation project(':sdkB')
implementation 'org.webrtc:google-webrtc:1.0.28032'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:preference-v14:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'io.michaelrocks:libphonenumber-android:8.4.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android:flexbox:1.0.0'
implementation 'com.github.woxthebox:draglistview:1.6.3'
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
// Google Lifecycle Components
implementation "android.arch.lifecycle:extensions:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
}
build.gradle of sdkA
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.webrtc:google-webrtc:1.0.28032'
implementation('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
// Google Lifecycle Components
implementation "android.arch.lifecycle:extensions:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
build.gradle of sdkB
dependencies {
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
}
How can solve it?
Thanks
Ok I've been tackling this issue myself for the last day or so. nightmare.
but I have it working now at least for the project I've been working on which is quite large and with lots of additional android dependencies.
See this issue where Mike Hardy has been a great help. https://github.com/mikehardy/jetifier/issues/27
I would recommend to avoid AndroidX until 0.60.0 has landed.
SOURCE OF THE PROBLEM
the source of the problem for most of us is the + range selector in gradle dependencies.
as shown here as an example in react-native-google-analytics-bridge:
compile "com.google.android.gms:play-services-analytics:${safeExtGet('googlePlayServicesVersion', '+')}"
compile "com.google.android.gms:play-services-tagmanager-v4-impl:${safeExtGet('googlePlayServicesVersion', '+')}"
for most of us we're not setting a googlePlayServicesVersion value in the top level android/build.gradle
so we'll want to specify googlePlayServicesVersion = "16.+" + because theres various other google service packages available and they're not all at the same version number. this will capture 16.X.X and not go above. 17.X.X holds further issues.
And we also want to set supportLibVersion to 28.0.0 which is used by the android support libraries: com.android.support:appcompat-v7 the most common.
SOLUTION
android/build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "16.+"
}
...
AndroidManifest.xml
top line:
<manifest
xmlns:tools="http://schemas.android.com/tools"
application tag:
tools:replace="android:appComponentFactory"
android:appComponentFactory="android.support.v4.app.CoreComponentFactory"
ensure your gradle-wrapper.properties using 4.10.1
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
and finally ensure you are not using android X.
gradle.properties:
android.enableJetifier=false
android.useAndroidX=false
Additional Step (You might need this)
failing that doesn't work try adding jetifier as well. We'll use this to run through your node_modules and ensure everything is using the non androidx libraries.
npm i jetifier --save-dev or yarn add jetifier --dev
then add to postinstall script
"scripts": {
"postinstall": "jetify -r"
}
Try applying the suggestion, adding
tools:replace="android:appComponentFactory"
to the application tag
How to install lettuce library on Android studio in Gradle files ?
https://lettuce.io
is there any solution to compile the library ?
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0’
}
In the lettuce's getting started section there is a section called For Gradle Users on how to add the library from gradle. I think just adding:
implementation 'io.lettuce:lettuce-core:5.1.3.RELEASE'
would work. You must check if you must adjust your current dependencies and/or modify your proguard rules.
Hope I helped.