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 the build.gradle file:

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

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

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

and

 multiDexEnabled true 

I add this to the android manifest:

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

But I have a mistake that I wrote above. I found many questions regarding this problem (app: packageAllDebugClassesForMultiDex), but not with this (duplicate entry: com / google / android / gms / internal / zzrf.class).

I tried some solutions, such as removing some Google libraries, but I don’t know what is related 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' } 
+6
source share
3 answers

I had the same problem. In my case, I used the Android home library used in the Android app. This means that there is 1 project with 2 separate modules, and the application module depends on the library module. Both have multidex support. The root cause was inconsistency between versions of Google Play services. In the application module, I used 7.8. +, And in the library I used 8.1. +. So I just updated both to the same 8.1. + And it is fixed for me. Therefore, I must check all the dependencies on which you depend, and perhaps 1 of them will use a version of the Google gaming services below yours.

+10
source

Delete all files in the build folder of this project. In my case, this is the jar file of the entire conflict of the google game with the jar file only for advertising.

+1
source

As I said in a comment: I created another project and just did the same: by installing google play and multidex services, the problem no longer appeared.

0
source

All Articles