13

Sorry if I asked a duplicate question, but I couldn't find a solution for this error. I surfed around stackoverflow,gradle site, android blogs, google search but there wasn't a working solution for several hours. I'm an android beginner so I not sure if I have missed something in other posts.

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

android {
         compileSdkVersion 23
         buildToolsVersion "23.0.0"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 22
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile 'com.android.support:appcompat-v7:22.2.1.'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
compile 'com.android.support:recyclerview-v7:22.2.1.'
compile 'com.android.support:cardview-v7:22.2.1.'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/applovin-sdk-6.0.1.jar')
compile files('libs/appodeal-1.13.1.jar')
compile files('libs/chartboost-5.2.0.jar')
compile files('libs/my-target-4.0.13.jar')
compile files('libs/unity-ads-1.4.7.jar')
}

The project was working fine until I add some libs from appodeal (those compile file lines). I have tried to build the project but gradle gave the errors.

:app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/widget/RecyclerView$ItemDecoration.class

There are also 2 more error of the same exception about duplicate entry- not sure why I got them: android/support/v4/PrintKitKat.class and android/support/multidex/MultiDex$V14.class.

I tried to upgrade gradle, invalidate and restart to clear cache, omit dependencies then rebuild/clean project, find potential duplicate module to exclude, and search projects for those .class but I found no duplication.

Iamat8
  • 3,888
  • 9
  • 25
  • 35
Phuong Dao
  • 185
  • 1
  • 2
  • 12
  • 2
    Perhaps one of your jars already contains RecyclerView library .jar/Support Multidex .jar/Support v4 .jar Try to not declare them by yourself. If it helps then you need to find a way to make Gradle "merge" duplicate dependencies. Unfortunatly looking at your dependency list I can't suggest which library can also depend on recyclerview/multidex-support/support-v4. – Lingviston Oct 06 '15 at 10:59
  • 4
    Could you execute **./gradlew app:dependencies** and attach result. – Oleksandr Oct 08 '15 at 10:18
  • I'm sorry for late reply, I've not able to get in stackoverflow of late. I double checked the external library tree as @Lingviston suggested and saw there were some duplication because I updated version of some dependencies so gradle downloaded 2 versions in different folders. I think it was working fine because I haven't add **multiDexEnable true**. But then when I add more libs from appodeal and the project went over 65k limit ( i thought so) then I have to use _multi dexing_ and gradle hasn't "merge" them. Thanks Alexandr for the command, it gave very comprehensive dependencies tree view. – Phuong Dao Oct 12 '15 at 04:19

1 Answers1

13

You can test putting this on root of directory in the Terminal

./gradlew clean
mafiu
  • 146
  • 1
  • 3