Gradle has multiple dependency configurations. I know that compile, implementation, api dependencies are shipped with the library/app; while compileOnly, testCompile, and testImplementation dependencies are not. What about the classpath dependencies in the top-level buildscript, are those dependencies included in the AAR/APK?
For E.g. Dokka (https://github.com/Kotlin/dokka) library, this only needs to be added as buildscript.classpath dependency, will dokka be included in the library aar file?
I tried searching in the Gradle docs but could not find an answer to my question. I am ssuming that it should not be shipped with the app/library.
I have a problem on my Android project, I can't build, this is the error I have:
Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
I tried many different solution I found but the problem persists.
I have the right dependencies and repositories on gradle file on project root:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
and
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
On my app gradle I have the following dependencies:
implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-analytics:15.0.2"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-tagmanager:15.0.2"
implementation "com.google.firebase:firebase-core:16.0.0"
Some suggestions?
The solution was update the following dependencies:
implementation "com.google.android.gms:play-services-analytics:16.0.0"
implementation "com.google.android.gms:play-services-tagmanager:16.0.0"
I just added right after the apply plugin: 'com.google.gms.google-services' at the bottom of my build.gradle :
apply plugin: 'com.google.gms.google-services'
// Work around
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
I had the same exact error, upgrading analytics was the key:
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
I know you thought everything is updated referring to the official website, but writing 15.0.0 and looking for suggestions works better.
Update project gradle play service dependency with latest release :
classpath 'com.google.gms:google-services:4.0.1' and
Update project firebase products usage as per firebase latest release note
this shoud be on top if you use firebase libraries:
implementation "com.google.firebase:firebase-core:16.0.0"
This worked for me.this shoud be on top if you use firebase libraries:
implementation "com.google.firebase:firebase-core:15.0.0"
In my case the issue was OneSignal, which somehow broke everything down.
They even have a dedicated library for this: https://github.com/OneSignal/OneSignal-Gradle-Plugin
and the actual issue was that OneSignal was inside my app-level gradle, instead of root one.
Freaking ridiculous!
Check Answer by Bhupendra Acharya from
https://groups.google.com/forum/#!topic/firebase-talk/XbGR-YrsTTA works for you. I got the following error
The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
While using
implementation 'com.google.firebase:firebase-core:16.0.1'
And resolved by updating the version
implementation 'com.google.firebase:firebase-core:16.0.4'
My problem was that I was importing oneSignal gradle plugin but I do not import the full apply plugin: 'com.google.gms.google-services'.
To fix I just had to add the implementations I was using.
For future users: Open build.gradle files and just hover your mouse on the dependencies and a tooltip gonna show up telling your the newest version and that should solve your problem.
Beware that Firebase Documentations does not have the newest versions.
update classpath for com.google.firebase:firebase-core:16+
classpath 'com.google.gms:google-services:4.2.0'
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
Try this one , place maven url on top inside repositories in build.gradle
Update build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' //< update version
classpath 'com.google.gms:google-services:3.1.1' //< update version
}
}
This would help you I guess
Update the build.gradle file from the project root folder. I've tried this and it was helping.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
----
}}
Make sure you added following line in bottom of app gradle
apply plugin: 'com.google.gms.google-services'
Make sure you are using compatible google-services in project level gradle
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
}
Check if you have added following dependency
implementation 'com.google.firebase:firebase-core:16.0.1'
I have answered a similar issue here. You need to keep versions of play services and firebase to latest one. Check here for links
https://stackoverflow.com/a/52696667/3333878
Try to set
classpath 'com.google.gms:google-services:3.2.1'
instead of
classpath 'com.google.gms:google-services:4.0.1'
It's helped in my case, but I don't know the cause of the error.
I used Firebase Cloud Message Service in my project. I read Firebase documentation for Integrate in android and see this line to add in build.gradle of project.
classpath 'com.google.gms:google-services:3.0.0'
My question is:
Why we have to use google-service version 3.0.0 ? Instead latest is 9.4.0.
Edition : Tnx Gabriele. As per #Gabriele its a plugin not library. So what is difference between Plugin and Library. What is different between DSL and API? Is API is depends on DSL or DSL is depends on API?
Don't confuse the buildscript dependencies with the library dependencies:
In your buildscript dependencies you are going to define the plugins used by your script. In this case you are adding the google-services plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
In the dependencies section you are going to define the libraries used.
dependencies {
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
}
I am setting up the first project of android with firebase following this Add Firebase to Android docs and stuck at resolving google play service dependency it says
I also google it but couldn't find any helpful answer.
In Project:Gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
In App:Gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-core:9.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Is anything i am missing? what should i do as i read my answers here at stackoverflow but none of them were useful
You have set up the plugin and dependencies correctly, but you need the google-services.json configuration file from the Firebase Console.
If you've not connected an app, select "Add Firebase to your Android app", enter the package name, and hit Add App. This should download the file.
If you connected before, click on the cog in the left nav, select Project Settings, and download the google-services.json associated with your project.
You need to download this and put in your app directory (next to the app build.gradle).
for me solved by add this In Project:Gradle
in :
buildscript {
///////////////////*blah blah*/
classpath 'com.google.gms:google-services:3.0.0'
repositories {
jcenter()
}
}
I have an app and an android library in my application, in development env i would like to provide a project level dependency i.e. dependency in the
(Project:XXX) build.gradle file.
This is how my project level build.gradle looks (partial view)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
compile 'io.reactivex:rxandroid:1.1.0'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex:rxjava:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I get an error Gradle DSL method not found : compile().
Is there a way in android to provide common project level dependency.
You can't add dependencies to any other scope except of classpath in the buildscript block.
Here's how you declare a project dependency (in another project, not in buildscript):
dependencies {
compile project(':shared')
}
You are using the dependencies block inside the buildscript. It is wrong.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
dependencies {
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
}