You've probably fixed this by now but just so this doesn't stay unanswered,
Try adding this to your build.gradle
:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
You need to check that you have inserted v4 library and compile library? You must not repeat library in your app or your dependence program.
delete the repeat library so that just one V4 remains.
in your app dir build.gradle
file
add this command:
android{
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}
it works for me! You can try it!
I also came across this kind issue when re import old eclipse project. It occurred some old dependency as jar file in the project.
just remove
compile fileTree(dir: 'libs', include: '*.jar')
in gradle file
and add dependency in the gradle file.
It works for me ..
In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true
in the build.gradle.
In order to fully resolve the error first of all have a look at Configure Apps with Over 64K Methods (espescially "Configuring Your App for Multidex with Gradle").
Furthermore search for occurences of the class that causes the "duplicate entry" error using ctrl+n in Android Studio. Determine the module and dependency that contains the duplicate and exclude it from build, e.g.:
compile ('org.roboguice:roboguice:2.0') {
exclude module: 'support-v4'
}
I had to try multiple module labels till it worked. Excluding "support-v4" solves issues related to "java.util.zip.ZipException: duplicate entry: android/support/v4/*"
My understanding is that there are duplicate references to the same API (Likely different version numbers). It should be reasonably easy to debug when building from the command line.
Try ./gradlew yourBuildVariantName --debug
from the command line.
The offending item will be the first failure. An example might look like:
14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar
14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'
14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'
In the case above, the aar file that I'd included in my libs directory (theOffendingAAR) included the Google Play Services jar (yes the whole thing. yes I know.) file whilst my BaseApp build file utilised location services:
compile 'com.google.android.gms:play-services-location:6.5.87'
You can safely remove the offending item from your build file(s), clean and rebuild (repeat if necessary).
check your dependencies versions, you must have compatible versions put attention specially to com.google packages, must have same version like:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
Both are 8.3.0, if you have another version compilation will throw that exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With