Reputation: 1567
Below is the error I am getting after adding the Firebase, google services in gradle and google-services.json in app module.
I have 13 modules in my app. I have 7 build variants in all the modules. I tried with placing the google-services.json in app module and placing it in build variant folder inside the app module. I am getting same error. I have the notification feature in one build variant.
I removed the firebase related code in gradle and google-services.json from application, it is working perfectly.
Due to security reason I can't share the entire file.
Main app module gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'com.github.hotchemi:permissionsdispatcher:2.0.7'
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.7'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.android.support:multidex:1.0.1'
}
In Application gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
}
:app:transformClassesWithJarMergingForSmePreDebug FAILED FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:transformClassesWithJarMergingForSmePreDebug'.>
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class
I reffered many links in StackOverflow for this issue. None fixed my problem. Any suggestions appreciated.
Edited push notification module gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
//compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
//compile ('com.google.firebase:firebase-messaging:9.8.0') {
//exclude group: 'com.google.android.gms'
//}
}
apply plugin: 'com.google.gms.google-services'
Upvotes: 0
Views: 928
Reputation: 991
This issue might because you have duplicate dependencies. One has latest version and the other one has old version.
What you can do is
check your app dependecies.
./gradlew clean :app:dependencies
find 3rd party libraries that also have com.google.android.gms included.
exclude this group from the library
compile ('library') {
exclude group: 'com.google.android.gms'
}
This might be able to be a quick fix. But it's not good!
The best solution should be updating your 3rd party library, their latest version might update their google services library already.
Upvotes: 2