Grumpy Cat Grumpy Cat - 2 months ago 248
Android Question

Error to build when update gradle dependency 9.4.0 to 9.6.1

Hello guys I just update my gradale dependancies but when I build my project it not building.

here is erroe code in grandel console


:app:processDebugGoogleServices
Found com.google.android.gms:play-services-ads:9.6.1, but version 9.4.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services:9.6.1, but version 9.4.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-gcm:9.6.1, but version 9.4.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-analytics:9.6.1, but version 9.4.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:9.6.1, but version 9.4.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
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 9.4.0.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED


here is my app level build gradel look like


.
.
.

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile files('libs/commons-codec-1.10.jar')
compile 'com.onesignal:OneSignal:3.0.3@aar'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'



all my google repository are up to date.
nothing shown in SDK manager to update.

how to fix this

thanks.

Answer

You're mixing different versions of Firebase and Google Play services. Don't.

ext.googlePlayVersion = "9.6.1"
compile "com.google.firebase:firebase-ads:$googlePlayVersion"
compile "com.google.firebase:firebase-database:$googlePlayVersion"
compile "com.google.android.gms:play-services-ads:$googlePlayVersion"
compile "com.google.android.gms:play-services:$googlePlayVersion"
compile "com.google.android.gms:play-services-gcm:$googlePlayVersion"
compile "com.google.android.gms:play-services-analytics:$googlePlayVersion"
compile "com.google.android.gms:play-services-location:$googlePlayVersion"

Note: Double quotes are mandatory otherwise the variable will be taken literally.


Make sure you're using latest Google services plugin, as of September 26 it's 3.0.0. Check your project build.gradle.

dependencies {
    classpath 'com.google.gms:google-services:3.0.0'
}
Comments