My project is a Chat app that uses Parse. After added other dependencies, this problem started appearing:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 2
Searching here in StackOverflow, some folks told me that it could be the 65K limit from Android.
So, to solve I followed the steps below:
1 - Add Multidex
DefaultConfig {
multiDexEnabled true
}
and
compile 'com.android.support:multidex:1.0.0'
https://developer.android.com/tools/building/multidex.html
2 - Enable Jumbo Mode in Android Gradle Settings
dexOptions {
jumboMode = true
}
I cleaned the project and ran the gradle build. It did not generate any errors. Great! But when I click "Run app" it generates this error below.
Error: Execution failed for task ': app:
packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException:
duplicate entry: bolts / AggregateException.class
If I remove the dependency 'com.parse.bolts: bolts-android: 1. +' the "Run app" works, but I can not do without the dependency of Parse.
This is my Gradle build script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "br.com.triangulum.mink"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse*.jar')
compile project('libraries:httprequest')
compile project('libraries:cameralibrary')
compile project('libraries:bgarefreshlayout')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:design:+'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.afollestad:material-dialogs:0.7.4.0'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'de.greenrobot:eventbus:2.4.+'
compile'com.edmodo:cropper:1.0.+'
compile 'com.github.ksoichiro:android-observablescrollview:+'
compile 'com.etsy.android.grid:library:1.0.5'
compile('com.mikepenz:actionitembadge:3.0.2#aar') {
transitive = true
}
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.android.support:multidex:1.0.+'
}
try to change this:
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
To this:
compile('com.android.support:multidex:1.0.0');
the bolds module is used sometimes to fix Duplicated dexLibs
Regards
Your com.facebook.android:facebook-android-sdk:4.1.0 library is messing with parse as both use same bolts-android module internally and having a different version of this module. Try to exclude this module from any of parse or facebook gradle dependency.
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
I was having the same problem and When I run ./gradlew yourModuleName:dependencies by the terminal, I found exactly which two libraries are messing with each other having a different version of the same module internally.
Related
I got this error when I run the code ->
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzafz.class
I have no idea what does it means and do I fix it. I need your help guys
I have treid several things but nothing really helped, I added "multiDexEnabled true" and that cause to that error.
Before that error O had "android error finished with non-zero exit value 2". After I added "multiDexEnabled true", it gives me this error:
"duplicate entry: com/google/android/gms/internal/zzafz.class Error"
How can I fix it, any help would be appreciated!
this is my Manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.world.bolandian.gpstracker"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
}
apply plugin: 'com.google.gms.google-services'
remove compile 'com.google.android.gms:play-services-maps:9.6.1' and clean-build the project
You are including both the legacy Firebase API:
compile 'com.firebase:firebase-client-android:2.3.1'
and the new Firebase APIs:
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
They should not be used together. Remove firebase-client-android:2.3.1 and follow the instructions in the Firebase Upgrade guide.
It is also important to use the same versions of Firebase and Play Services libraries. Don't use 9.6.1 of play-services-maps and 9.2.1 of the Firebase libs. The latest versions available are 10.0.1. Consider updating all of your dependencies to use the latest versions.
Update:
I copied the dependencies you posted and was able to reproduce the error. After I replaced the dependencies with these, the error was resolved. Do these not work for you?
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
}
I'm trying to add a library to my project, right now my current build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "com.example.guycohen.cheaters"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
// Enabling multidex support.
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:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.whl.handytabbar:library:1.0.4'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
}
When I add a new library
compile 'com.github.navasmdc:PhoneTutorial:1.+#aar'
I get this error:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelperKitkat$2$1.class
I've tried to fix this issue by adding
configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
I couldn't find a duplicate class in my project.
I'm sure whether if I could delete the duplicate entry it would run perfectly, but I'm not sure how I'd find it.
compile 'com.android.support:support-v4:22.1.1'
compile ('com.android.support:appcompat-v7:22.1.1') {
exclude module: 'support-v4'
}
compile ('com.facebook.android:facebook-android-sdk:4.2.0') {
exclude module: 'support-v4'
}
compile ('com.github.navasmdc:PhoneTutorial:1.+#aar') {
exclude module: 'support-v4'
}
I use this to replace all support libraries versions with the latest one that i use in gradle file:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion "26.0.1"
}
}
}
}
Try using this versions in build.gradle file.
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
Your Error:
java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelperKitkat$2$1.class
Step 1:
In this case main hint is android/support/v4/print/PrintHelperKitkat$2$1.class
Step 2: Searching for the class, in your case the "PrintHelperKitkat.class" (in AndroidStudio just hit Ctrl+N on Windows or CMD-O on Mac)
Step 3: See which jar contains it - Android Studio will write it in the popup.
Step 4: Exclude it from all builds,
for example:
com.android.support:support-v4:_____
compile('your_conflicted_dependency')
{
exclude module: 'support-v4'
}
In my case my one dependency also included in my another AAR. So I
deleted that dependency
I was faced the same issue. I solved it by,
Make sure that in all imported project's build.gradle file should have same compileSdkVersion and dependencies versions like in your project's build.gradle file.
It will remove this error.
I am attempting to integrate Pushy (https://pushy.me/) into my app to allow for more reliable real-time notifications, in place of GCM.
However, upon attempting to run the app, the error below appears:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/fasterxml/jackson/core/base/GeneratorBase$1.class
Below is my build.gradle class:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1" // 22.0.1
defaultConfig {
applicationId "com.example.android.myapp2"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
dataBinding {
enabled = true
}
}
dependencies {
compile 'com.android.support:design:23.1.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.firebase:firebase-client-android:2.5.1+'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I have attempted to clean, rebuild, but nothing helps.
How can I alleviate this issue?
After contacting the support line, I simply needed to prevent duplicate references of the jackson library:
configurations {
all*.exclude group: 'com.fasterxml.jackson.core'
}
and changed the dependencies to:
dependencies {
compile 'com.android.support:design:23.1.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.firebase:firebase-client-android:2.5.1+'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile files('libs/pushy-1.0.7.jar') //** Specified **
}
I'm using the YouTube SDK to play videos in a viewpager. As soon as I run the app, this error is thrown:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/youtube/player/internal/u.class
Manifest.xml:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.xxxxx.www.xxx"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.thefinestartist:ytpa:1.2.1'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32#aar'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7#aar') {
transitive = true
}
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32#aar'
}
I can't include
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
as viewpager uses support library v4
That error comes when any of your jar dependency have same class. Make sure you have not added support jar both as gradle and jar dependency. There might be duplicate references to the same API.
Try ./gradlew yourBuildVariantName --debug from the command line. You can safely remove it from the project or from your build file(s), clean using the command ./gradlew clean and rebuild the project(repeat if necessary).
Check this related SO questions Gradle Duplicate Entry: java.util.zip.ZipException and java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex.
I observed the same issue after Android Studio upgrade to version 2.2 Preview 6
Then I deleted lines:
compile(name: 'YouTubeAndroidPlayerApi', ext: 'jar')
and
flatDir { dirs 'libs'}
from two build.gradle files and the issue is gone.
Looks like 'libs' directory is built automatically now but I'm not able to find any confirmation on Google pages.
Add
dependencies {
compile 'com.android.support:support-v4:24.2.1'
}
in build.gradle file.
I have just added the paypal sdk and the following error occurred when building:
Error:Execution failed for task ':app:dexRelease'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2
I have seen many threads suggesting that I add
multiDexEnabled true
but this does not work on api 18 and below. Also, It brings other errors with my facebook sdk.
Is there any other way I can handle this error?
Here's my build.gradle:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.edwardokoth.myapp"
minSdkVersion 15
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories { mavenCentral() }
dependencies {
compile files('libs/Parse-1.9.4.jar')
compile files('libs/ParseFacebookUtilsV4-1.9.4.jar')
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(include: 'ParseFacebookUtilsV4-*.jar', dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'commons-io:commons-io:+'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1#aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:0.6.3'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.android.support:design:22.2.1'
compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
}
Check if there are libraries conflicts ( same library but different version ). In this case i supose you should exclude support library module from Facebook SDK.
compile ('com.facebook.android:facebook-android-sdk:4.6.0'){
exclude group: 'com.google.android', module: 'support-v4'
}