Search code examples
androidannotationsandroid-gradle-pluginrenderlibs

Duplicate class in two offcial android libs, gradle fails


I'm using a library that requires activate render script support mode. Like this

defaultConfig {

 minSdkVersion 14
 targetSdkVersion 23
 renderscriptTargetApi 20
 renderscriptSupportModeEnabled true
}

But when I try to run the app, I have this:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/annotation 
/Keep.class

Keep.class is in annotation-support lib and in rendserscript lib too, both from Google, so I don't know what to do exactly.


Solution

  • This error occurred in latest(23) SDK version only. Can you try to change the build version to 22 or 21, change the dependencies also.

    For example

    android {
           compileSdkVersion 21
            buildToolsVersion "21.1.2"
    }
    dependencies {
    
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile 'com.android.support:support-v4:21.0.3'  
    }