APP Bird APP Bird - 2 months ago 29
Android Question

duplicate entry error after adding google services

I wanted to add firebase to one of my app. I integrated firebase according to firebase offical documents. but when I tried to "run" app. it gives me this warning


Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzc.class


I removed all the firebase coding & removed it from gradle file. but error still exist untill I remove this line

apply plugin: 'com.google.gms.google-services'


but unfortunately I need google services to work with firebase. here is my app gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'

defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 22
versionCode 15
versionName "2.01"
multiDexEnabled true
}

dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/main.jar')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.commit451:NativeStackBlur:1.0.1'
compile 'com.google.firebase:firebase-analytics:9.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.facebook.android:audience-network-sdk:4.11.0'
}
apply plugin: 'com.google.gms.google-services'


here is my project gradle file

buildscript {
repositories {
jcenter()
}
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
}
}

allprojects {
repositories {
jcenter()
}
}

Answer

The problem was with Facebook Audience network. once I excluded google services it worked fine. If anyone having same problem change your audience network dependency like this

   compile ('com.facebook.android:audience-network-sdk:4.11.0'){
     exclude group: 'com.google.android.gms'
 }