My gradle file is not throwing any error while building. But, when I run Android lint, it fails with incompatible gradle version error.
Sharing the error:
Incompatible Gradle Versions
../../build.gradle: All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1. Examples include com.google.android.gms:play-services-measurement-base:16.0.2 and com.google.android.gms:play-services-measurement-api:16.0.1**
Sharing the google dependencies defined in app level gradle:
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:gridlayout-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support:preference-v14:27.1.1'
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:16.0.0'
compile 'com.google.android.gms:play-services-auth:16.0.0'
compile 'com.google.firebase:firebase-core:16.0.3'
compile 'com.google.firebase:firebase-messaging:17.3.0'
compile 'com.google.code.gson:gson:2.8.2'
Project level gradle file:
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:1.5.0'
Which dependency making this lint error? How to solve this gradle incompatibility issue?
I have tried changing all google gms versions to 15, but it didn't solved the issue..
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:15.0.2'
compile 'com.google.android.gms:play-services-auth:15.0.1'
It happens because you are using an old plugin
classpath 'com.google.gms:google-services:1.5.0'
and different versions of the Google Services libraries.
You should update the Google Services Gradle Plugin:
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
// ...
}
Then update your dependencies but it not necessary to use the same version.
Starting from plugin 3.3.0 there is a different behaviour:
Google Play services libraries after 15.0.0 now have independent
version numbers which follow SemVer. This change will allow for more
frequent, flexible updates by individual components. The Google
Services Gradle plugin has been updated to version 3.3.0 to support
this change in versioning.
Check also the documentation:
REMOVE THIS OLD PATTERN:
buildscript {
ext {
play_version = '15.0.0'
}
}
dependencies {
// DON’T DO THIS!!
// The following use of the above buildscript property is no longer valid.
implementation "com.google.android.gms:play-services-ads:${play_version}"
implementation "com.google.android.gms:play-services-auth:${play_version}"
implementation "com.google.firebase:firebase-firestore:${play_version}"
}
Now each dependency that you use may now be at different versions.
You need to update gradle build tools to this version:-
classpath 'com.android.tools.build:gradle:3.2.1'
and google play services
classpath 'com.google.gms:google-services:3.2.0'
The error message
All com.google.android.gms libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1.
is very clearly telling that
This is what you have right now:
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:16.0.0'
it must be:
compile 'com.google.android.gms:play-services-location:16.0.2'
compile 'com.google.android.gms:play-services-maps:16.0.2'
compile 'com.google.android.gms:play-services-analytics:16.0.2'
Also, try to always use the latest version of Google APIs.
Hope this will help you.
adding to #Nouman Ch answer , These are the latest dependencies
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.6'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
check here and here for finding latest versions
Go to project view of android studio. There in .idea> libraries you'll find libraries with versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1.
These libraries are imported as dependencies of the ones you have in your build.gradle file. Import the latest versions of those libraries in your dependencies to remove the error.
This question already has answers here:
Dependancy error when integrating android studio project with Firebase for a google sign in feature
(4 answers)
Closed 4 years ago.
I'm trying to connect firebase to my application.
after pressing "Add firebase authentication to your app" Im getting the following error:" Failed to resolve: firebase-auth-15.0.0"
That leads me to the dependencies in build.gradle(module:app).
the error:
implementation 'com.android.support:appcompat-v7:28.0.0'
the details on the error:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
My entire dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
}
In your root-level build.gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
In your module build.gradle:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.0.5'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
I'm trying to coax a number of android libraries to play nicely together but I'm becoming frustrated with the versioning system.
I've managed to get the firebase version of crashlytics working but I cannot currently get this to work well with admob:
in my app 'build.gradle' I have the following dependency section:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.0.5'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation 'com.google.android.gms:play-services-ads:16.0.1'
}
Which produces this error:
Failed to resolve: com.google.android.gms:play-services-ads:16.0.1
'16.0.4' also fails whereas '17.1.1' produces this error:
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-core#16.0.1
-- Project 'app' depends onto com.google.android.gms:play-services-ads#17.1.1
thinking that maybe all of the dependencies need to be '17.1.1' results in gradle not finding 'com.google.firebase:firebase-core:17.1.1'
I doubt I'm alone in finding this version soup somewhat opaque. Is there an easier way to ensure a set of libraries that work well together?
Add:
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
and in top level gradle file use the latest version of google play services:
classpath 'com.google.gms:google-services:4.0.2'
Note:
You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before jcenter():
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Please use the following version:
implementation 'com.google.android.gms:play-services-ads:17.1.1'
Also update the firebase-core library to version 16.0.4:
implementation 'com.google.firebase:firebase-core:16.0.4'
I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning :
I tried to look for "compile " in the whole project but no match was found. So what could be the cause?
I've updated com.google.gms:google-services from 3.1.1 to 3.2.0 and the warning stopped appearing.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath("com.google.gms:google-services:3.2.0")
}
}
I have one same Warning caused to com.google.gms:google-services.
The solution is to upgrade classpath com.google.gms:google-services to classpath 'com.google.gms:google-services:3.2.0' in file in build.gradle Project:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In Android Studio verion 3.1 dependencies complie word is replaced to
implementation
dependencies with Warning in android studio 3.1
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
dependencies OK in android studio 3.1
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Gradel generate by Android Studio 3.1 for new project.
Visit https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html
For details https://docs.gradle.org/current/userguide/declaring_dependencies.html
I've updated com.google.gms:google-services from 3.2.0 to 3.2.1 and the warning stopped appearing.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
}
}
Using the currently latest version of the google gms services resolved it for me.
In the project level build.gradle:
buildscript {
...
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
...
}
}
Open up your build.gradle file located here:
This is the old way of writing the dependency libraries (for gradle version 2 and below):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:support-v4:21.+'
}
This is the new (right) way of importing the dependencies for gradle version 3:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation files('libs/volley.jar')
implementation 'com.android.support:support-v4:21.+'
}
Reply by google : https://issuetracker.google.com/issues/74048134
There would be some dependency still using compile, check your application dependencies and transitive dependencies carefully.
https://issuetracker.google.com/issues/72479188 indicates that plugins sometimes can introduce "compile" dependencies and that's what triggers the warning. Probably just easiest to star that issue and wait until they fix it to point out which plugins are causing the issue.
No need to remove the line. As Jkrevis wrote, update the com.google.gms:google-services to 3.2.0 and it stops the warnings.
In my case,it is cause by Realm library,after I update it to latest version(5.1.0 so far) of Realm,the problem solved!
Here is the working gradle script:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.realm:realm-gradle-plugin:5.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
I encounter this problem without using com.google.gms:google-services.
The solution solving this kind problem as below:
check build.gradle files of all projects and modules. Or just global search key word 'compile' to find where cause this warning.
if above method cannot solve this warning, then use CLI Command,
./gradlew assembleDebug -d > gradle.log
print detail debug information to a file named gradle.log or any else, as the information is too much. Then search word "WARNING" to find the position in gradle.log, usually you can find what dependence or plugin cause the warning.
Just updating google-service version did not work for me.
First make sure all your dependencies compile are replaced with implementation.
Update all dependencies in your project. Because if one of your dependency is having compile then your project will show this error. So update all dependencies version.
I have tried changing the google gms services to the latest com.google.gms:google-services:3.2.1 in Android Studio 3.0.1 but the warning still persists.
As recommended by the compiler,I changed all compile dependencies to implementation and testCompile to testImplementation like this..
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-ads:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
And finally the warning is removed!
go to your build.gradle file in project level you will find the following lines highlighted
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' //place your cursor over here
//and hit alt+enter and it will show you the appropriate version to select
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.2' //the same as previously
}
In my case it was an old dependency that was using compile for the transitive dependencies : com.jakewharton.hugo
After removing it from my gradle it compiled.
The workaround to solve this problem was for me that I used an older version of Gradle, which can be found here:
I used the gradle-3.0-rc-1-src version, but others may work too, although probably it should not be newer than the 3.0-version.
First extract the zip file to anywhere you like.
Then go to File -> Settings -> Build, Execution, Deployment -> Gradle and change the setting to Use local gradle distribution. After that make sure that the Gradle Home-field is pointing to the .gradle directory in the directory you just unzipped to.
Rebuild the project and everything should be ok.
The current version is 4.2.0:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.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'
}
}
Google updated it's services recently in September 2021. Gave update and I faced same issue then I update the build.gradle file in android studio
Old version with issue
classpath 'com.google.gms:google-services:4.3.3'
Updated code in build.gradle
classpath 'com.google.gms:google-services:4.3.10'
You can do this two options:
Add classpath 'com.google.gms:google-services:3.2.0' in ur project: build.gradle dependencies
and
Replace your module: build.gradle in dependency from complile with implementation
and you wont get any warning messages.
Just add from build.gradle from build script
classpath 'com.google.gms:google-services:3.2.0'
and all of the dependencies "compile" replace to "implementation".
that worked from me.
For me changing compile to implementation fixed it
Before
compile 'androidx.recyclerview:recyclerview:1.0.0'
compile 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
After
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
I treid all the solutions mentioned here, but no luck.
I found in my build.gradle file as below:
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
I just changed it as below and saved and tried build success.
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
Hope that you're affected with build.gradle(app)
If do so , follow this step
Replace compile with androidTestImplementation in build.gradle
androidTestImplementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support:design:27.1.1'
so simple ! hope this will solve
In my case the issue was the Google services gradle plugin with the following line in the gradle file:
apply plugin: 'com.google.gms.google-services'
Removing this resolved the issue
go to you build.gradle (app level)
build.gradle module app
and replace the word "compile" by "implementation"
it will work 100%
About FireStore configuration in existing projects. [ANDROID]
I tried to include and configure it according to the support material and it did not work.
Error while adding dependencies in Gradle-App.
Dependency that is in the Firebase tutorial: compile 'com.google.firebase:firebase-firestore:11.0.6'
Note: I tried to put it as 10.2.6, and also tried to update all dependencies for the same version of FireStore. Nothing worked.
I currently have versions 10.2.6 of the Firebase services.
compile 'com.google.firebase:firebase-auth:10.2.6'
compile 'com.google.android.gms:play-services-auth:10.2.6'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.google.firebase:firebase-database:10.2.6'
compile 'com.google.firebase:firebase-storage:10.2.6'
compile 'com.google.firebase:firebase-core:10.2.6'
Error:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.6.
Note:
I checked the PlayService and Repository updates. And I also checked on the dependencies in Gradle:
classpath 'com.google.gms:google-services:3.1.0'
add
compile 'com.google.firebase:firebase-firestore:11.4.2'
You don't need com.google.firebase:firebase-database if you use Firestore alone.
and you don't need to compile all google services.
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
}
}
dependencies {
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-firestore:11.4.2'
}
apply plugin: 'com.google.gms.google-services'
But if you want to change versions easier to avoid conflict you should use gradle "ext" :
buildscript {
ext.play_service_version = '11.4.2'
ext.firebase_version = '11.4.2'
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
}
}
dependencies {
compile "com.google.android.gms:play-services-auth:${play_service_version}"
compile "com.google.firebase:firebase-auth:${firebase_version}"
compile "com.google.firebase:firebase-storage:${firebase_version}"
compile "com.google.firebase:firebase-core:${firebase_version}"
compile "com.google.firebase:firebase-firestore:${firebase_version}"
}
apply plugin: 'com.google.gms.google-services
Keep in mind that play-service-version and firebase-version should be the same.
Use compile 'com.google.firebase:firebase-firestore:11.4.2'
Cloud Firestore was introduced in Google Play services 11.4.2
Do not forget to add this line in the bottom of build.gradle:
apply plugin: 'com.google.gms.google-services'
How about your SDK versions?
it is in the build.gradle app level
make sure its the latest:
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"