Hector
Hector

Reputation: 129

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.

Upvotes: 2

Views: 2340

Answers (2)

Reid Mac
Reid Mac

Reputation: 2499

I made the following modifications to my build.gradle file, and it is now working:

renderScriptTargetApi 23

and added

configurations { all*.exclude group: 'com.android.support', module: 'support-annotations' }

I believe it's the second line that did the trick.

Upvotes: 0

MathankumarK
MathankumarK

Reputation: 2905

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'  
}

Upvotes: 1

Related Questions