Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio Execution failed for task ':app:packageAllDebugClassesForMultiDex'

I have this error :

Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzrf.class

I want to add google play services to my project so i put this line in build.gradle file :

compile 'com.google.android.gms:play-services:7.8.0'

So I had to enable multidex and I followed android doc, adding this in build.gradle :

compile 'com.android.support:multidex:1.0.1'

and

multiDexEnabled true

I add this in android manifest :

<application 
...
android:name="android.support.multidex.MultiDexApplication">

But I have the error I wrote above. I've found a lot of questions relative to this problem (app:packageAllDebugClassesForMultiDex) but not with that (duplicate entry: com/google/android/gms/internal/zzrf.class).

I tried some solutions like remove some google libraries but I don't know what refers to internal/zzrf.class.

Here is my gradle file :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "fr.djey.testgoogleplus"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:multidex:1.0.1'
}
like image 419
Jey10 Avatar asked Aug 23 '15 09:08

Jey10


1 Answers

I faced same problem. In my case I used home made Android library used by My Android app. Which means 1 project with 2 separate modules, while the app module depends on the library module. Both have support of multidex. The root cause was inconsistency between google play services version. In the app module I used 7.8.+ and in the library I used 8.1.+. So I just updated both to same 8.1.+ and that fixed for me. So my answer is to check all the libs you depend on and may 1 of them using google play services version below yours.

like image 145
michael Avatar answered Nov 14 '22 21:11

michael