How does this happen when I try to deploy? In what library is this class ?
Note: It compiles and builds just fine, but this error shows up only when I try to deploy.
:myProject:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myProject:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/gdata/util/common/base/Escaper.class
These are the dependencies in my project, required by 4 different modules:
compile files('libs/gson-1.7.1.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/icu4j-4_8_1_1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/comscore.jar')
compile files('libs/javabase64-1.3.1.jar')
compile files('libs/libGoogleAnalytics.jar')
compile files('libs/urbanairship-lib-2.1.2.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:23.0.1'
Just like Mamata Gelanee said in the comments, the solution is to use maven repos instead of .jar's in /libs.
I've gotten rid of all jar's in my /libs folder and replaced it with maven repos and now it all builds and deploys fine.
Related
thank you for your support.
My issue is : When I added the multidex dependecy and try to export the signed apk, I get this error :
Error:Execution failed for task
':androidKeyboardThemes:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/location/ActivityRecognition$1.class
My gradle dependecies are theses:
dependencies {
compile project(':cropper')
compile 'com.google.android.gms:play-services:+'
compile files('libs/StartAppInApp-2.4.7.jar')
compile files('libs/google-play-services.jar')
compile 'com.android.support:multidex:1.0.1'
}
I tried to delete one lib or jar at any time and build again but I couldn't get the job done.
Also I read all the unswer about duplicated class in stackoverflow but I failed again to solve my issue.
Any ideas?, thank you for your help.
dependencies {
compile project(':cropper')
compile 'com.google.android.gms:play-services:+' <-- choose either one
compile files('libs/StartAppInApp-2.4.7.jar')
compile files('libs/google-play-services.jar') <-- choose either one
compile 'com.android.support:multidex:1.0.1'
}
Whatever it is, please dont use play-services. inside compile 'com.google.android.gms:play-services:+' contains alot of dependencies.. see below.. using play-services may cause dex problem and heavy app. refer here
I imported some existing Eclipse based Android projects into Android Studio. Along, the way I fixed several issues and I am hitting this one last issue (hopefully):
Execution failed for task ':myapp:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/mypackage/myapp/BuildConfig.class
Here are dependencies:
module1:
dependencies {
provided files('src/main/libs/opencv.jar')
}
module2:
dependencies {
compile files('libs/autobanh.jar')
compile files('libs/libjingle_peerconnection_java.jar')
}
module3:
dependencies {
compile 'com.google.code.gson:gson:2.2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:+'
compile files('src/main/libs/gcm.jar')
}
module4:
dependencies {
compile project(':module3')
compile 'com.google.android.gms:play-services:+'
}
Finally the App:
dependencies {
compile project(':module1')
compile project(':module2')
compile project(':module3')
compile project(':module4')
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
}
How do I fix this? I tried the following so far:
transformClassesWithJarMergingForDebug,com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
Execution failed for transformClassesWithJarMergingForDebug'. (Volley)
with no help. Any thoughts?
The error says
duplicate entry: com/mypackage/myapp/BuildConfig.class
BuildConfig is a class generated for each module (Android library or application) according to package name specified in its manifest.
Make sure all your modules have a unique package name in their AndroidManifest.xml
I've always programed Android with Eclipse and decided to start migrating to Android Studio.
In my project, I added some libraries...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
/* For Google Play Services */
//Firebase
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:cardview-v7:23.+'
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.firebase:firebase-client-android:2.3.0'
compile 'com.firebaseui:firebase-ui:0.2.2'
}
I got error in build gradle.
Error:A problem occurred configuring project ':app'.
> Could not download firebase-client-jvm.jar (com.firebase:firebase-client-jvm:2.3.0)
> Could not get resource 'https://jcenter.bintray.com/com/firebase/firebase-client-jvm/2.3.0/firebase-client-jvm-2.3.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/firebase/firebase-client-jvm/2.3.0/firebase-client-jvm-2.3.0.jar'.
> peer not authenticated
I released that: I didn't add firebase-client-jvm-2.3.0 library to complie. But I got this error.
I tried this but issue is not resolve.
Could you explain and help me resolve it?
Possible duplicate of Gradle Could not HEAD https://..pom > peer not authenticated - you should use HTTP instead of HTTPS in repo URL:
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
one that says, Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcompat-v7:21.1.2.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar
file:/C:/Users/Richard/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom
file:/C:/Users/Richard/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar
file:/C:/Users/Richard/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom
file:/C:/Users/Richard/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar
Required by:
MyApplication:app:unspecified
And another one that says:
Error:(28, 13) Failed to resolve: com.android.support:appcompat-v7:21.1.2
Install Repository and sync project<br>Show in File<br>Show in Project Structure dialog
The Appcompat v 21.1.2 doesn't exist.
Check here the releases.
You can use:
You can use one of these:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.0'
I'm pretty new to Gradle. My project is compiling file when I do a
./gradlew assembleDebug
But it doesn't when I try to run the tests:
./gradlew connectedCheck
I get (a couple of them):
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/facebook/AccessToken$SerializationProxyV1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
at com.android.dx.command.dexer.Main.processClass(Main.java:490)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
at com.android.dx.command.dexer.Main.access$400(Main.java:67)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
at com.android.dx.command.dexer.Main.processOne(Main.java:422)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
at com.android.dx.command.dexer.Main.run(Main.java:209)
at com.android.dx.command.dexer.Main.main(Main.java:174)
at com.android.dx.command.Main.main(Main.java:91)
here is the structure of my project:
main app depends on:
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:gridlayout-v7:18.0.+'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.jakewharton:butterknife:2.0.1'
compile 'com.squareup.retrofit:retrofit:1.1.1'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.okhttp:okhttp:1.2.0'
compile project(':Library:mylib')
mylib depends on:
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/facebooksdk.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
the exception is coming for each jars from mylib, after this line:
:Library:mylib:dexTest
any idea?
The already added error occurs when a library is referenced more than once. What I'd do is set the compile project as the first compile element in your app and delete the repeated support-library:
app depends on:
compile project(':Library:mylib')
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.jakewharton:butterknife:2.0.1'
compile 'com.squareup.retrofit:retrofit:1.1.1'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.okhttp:okhttp:1.2.0'
lib depends on:
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/facebooksdk.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
I encountered the same error but the message behind already added: is slightly different. It's about duplicate support-v4. What I did to tackle is:
compile('de.keyboardsurfer.android.widget:crouton:1.8.1') {
exclude(group: 'com.google.android', module: 'support-v4')
}
Hope it show you a new direction to fix your issue.
UPDATE:
Sorry, I didn't read your question carefully. Turns out you got problem with the connectedCheck task. Mine is when running gradle build. Right now, when I run gradle connectedCheck, I just faced the same error. I even tried with the IDE but none of them worked.
There are actually a discussion about it here https://code.google.com/p/android/issues/detail?id=61429 too. Due to the comment #8, if you move to the app folder and run above task, you may manage. Assume that the app folder is app-project/app, the libs are put in app-projecct/libraries/my-lib-1. Previously, I run in app-project and failed.
Hope it fix.