Error:Execution failed for task ':packageAllDebugClassesForMultiDex' - android

I'm trying to implement youtube search in my application. I have got the following error
Error:Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class
Here is my gradle file
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'com.google.guava:guava:18.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev145-1.20.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
compile project(':qsmack322')
compile project(':viewpagerindicator')
compile project(':Emojicon')
compile project(':CircleLoader')
compile files('libs/acra-4.5.0.jar')
compile files('libs/android-sqlite-asset-helper.jar')
compile files('libs/aws-android-sdk-2.1.7-core.jar')
compile files('libs/aws-android-sdk-2.1.7-s3.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/daocore.jar')
compile files('libs/gcmnoti.jar')
compile files('libs/google-api-client-1.4.1-beta.jar')
compile files('libs/google-api-client-googleapis-1.4.1-beta.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/jackson-core-asl-1.6.7.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/rebound-v0.3.3.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/universal-image-loader-1.9.1-with-sources.jar')
}
Pls help me!!!

duplicate entry, this may mean
compile files('libs/google-api-client-1.4.1-beta.jar')
compile files('libs/google-api-client-googleapis-1.4.1-beta.jar')
remove one of them ..

Try to add multiDexEnabled true in your gradle
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.your.package"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
}
}

Related

I am getting these errors while running my Android code

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/measurement/zzabn;
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "quotspot.inext.quotspot"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
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:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.firebase:firebase-core:15.0.0'
compile 'com.google.firebase:firebase-messaging:15.0.0'
compile 'com.google.firebase:firebase-storage:15.0.0'
compile 'com.firebaseui:firebase-ui:0.4.2'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
compile 'com.google.firebase:firebase-auth:15.0.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.firebase:firebase-firestore:15.0.0'
compile 'com.larswerkman:HoloColorPicker:1.5'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
Firebase was updated yesterday (5/2), causing the various firebase dependencies you are importing to go out of sync.
The solution is to update them to the latest version, which you can find by:
Go to Firebase release notes for the list of latest versions, or
open build.gradle file in Android Studio and see which Firebase dependencies are highlighted, put cursor above each of them to see the latest version number
try adding multiDexEnabled true in
android {
compileSdkVersion 27
defaultConfig {
applicationId "quotspot.inext.quotspot"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
To solve this, please change all these lines of code:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.firebase:firebase-core:15.0.0'
compile 'com.google.firebase:firebase-messaging:15.0.0'
compile 'com.google.firebase:firebase-storage:15.0.0'
compile 'com.firebaseui:firebase-ui:0.4.2'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
compile 'com.google.firebase:firebase-auth:15.0.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.firebase:firebase-firestore:15.0.0'
compile 'com.larswerkman:HoloColorPicker:1.5'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:multidex:1.0.1'
}
to
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-messaging:15.0.2'
compile 'com.google.firebase:firebase-storage:15.0.2'
compile 'com.firebaseui:firebase-ui:3.3.1'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
compile 'com.google.firebase:firebase-auth:15.1.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.firebase:firebase-firestore:16.0.0'
compile 'com.larswerkman:HoloColorPicker:1.5'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:multidex:1.0.1'
}
For more informations, please see this link and this.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > error

Please help me to find a solution on this error.. When I build my project I got an error like this
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbq.class
Please check ones my build.gradle(App level) file... Please give me a hint to move farword
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.realmilk.app.new"
minSdkVersion 15
targetSdkVersion 25
versionCode 6
versionName "1.0.6"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':volley')
compile project(':materialviewpager')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'io.github.yavski:fab-speed-dial:1.0.3'
compile 'com.wdullaer:materialdatetimepicker:2.2.0'
compile 'com.jaredrummler:material-spinner:1.0.5'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'me.tatarka.support:jobscheduler:0.1.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha2'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
testCompile 'junit:junit:4.12'
}
Please give me your valuable suggestions... Thanks
You are using 2 different versions of play service.
Change
compile 'com.google.android.gms:play-services-analytics:8.1.0'
to
compile 'com.google.android.gms:play-services-analytics:9.2.1'
So that both the auth and analytics service have same versions.
Similar question.
https://stackoverflow.com/a/38201741/3111083.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/MessageConstraintException.class

I migrate my Android eclipse project to Android Studio project, but when I try to run my app it flags the following error--
Error:Execution failed for task ':wikiNews:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/MessageConstraintException.class
For more information below is my build.gradle file--
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.abc.wikiNews"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':easyAndroidAnimationsLibrary')
compile project(':liveSdk')
compile project(':main')
compile project(':zbarSample')
compile project(':stickyHeaderLibrary')
compile project(':starBar')
compile project(':facebookSDK')
compile project(':library')
compile project(':ffmpeg4android_lib')
compile project(':socialNetworkingLib')
/*compile 'com.google.android.gms:play-services:+'*/
compile 'com.google.android.gms:play-services:9.6.1'
/*compile 'com.android.support:appcompat-v7:23.4.0'*/
/* compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'*/
compile files('libs/nmdp_speech_kit.jar')
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile files('libs/commons-logging-1.2.jar')
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/devsmartandroid.jar')
compile files('libs/google-api-client-1.6.0-beta.jar')
compile files('libs/google-api-services-plus-v1-1.3.0-beta.jar')
// compile files('libs/google-oauth-client-1.6.0-beta.jar')
compile files('libs/httpclient-4.4.jar')
compile files('libs/httpcore-4.4.jar')
// compile files('libs/thttpmime-4.3.5.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/signpost-commonshttp4-1.2.1.2.jar')
compile files('libs/signpost-core-1.2.1.2.jar')
compile files('libs/signpost-jetty6-1.2.1.2.jar')
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3')
{
exclude module: "httpclient"
}
}
Also please let me know if I can provide more information. Thank you.
Remove these dependencies in your gradle file :
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
And dd this dependency in your gradle file :
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

TransformException after migrating to Android Studio

I tried to import a working Eclipse Android project to Android Studio. I am working on Mac with the latest version of Android Studio. When I try to build, it keeps on displaying this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/api/client/http/AbstractHttpContent.class
The class generating this issue is in the com.google.http-client:google-http-client-gson:1.20.0 library, in the com.google.api.client.http package. I tried many things with the app.gradle file, such as excluding the com.google.api.client.http group but nothing works. Here is my app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.time2"
minSdkVersion 17
targetSdkVersion 19
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions.encoding = 'ISO-8859-1'
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile 'com.stripe:stripe-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
You should avoid manually adding in libs to your project.
E.g. change
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
to
compile 'commons-io:commons-io:2.4'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
Please verify that these are the correct packages. Let us know what you find after updating?
The library 'com.google.http-client:google-http-client-gson:1.20.0' is composed of the following nine modules:
google-http-client
google-http-client-android
google-http-client-appengine
google-http-client-xml
google-http-client-protobuf
google-http-client-jdo
google-http-client-jackson
google-http-client-jackson2
google-http-client-gson
Some of these e.g. google-http-client is included again in tour dependencies as a jar. Hence the duplicate entry.
Check this link for getting the setup right when using google-http-java-client. It has step by step instruction - Setup Instructions

Error ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry:

I am developing android application for Home Automation using gradle in Android Studio. There is no problem when I build the project, but when I try to run the project, there is an error like this:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: org/apache/http/params/CoreConnectionPNames.class
Here is my build.gradle codes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.cpl"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/android.jar')
compile files('libs/bcprov-jdk15on-1.47.jar')
//compile files('libs/google-play-services.jar')
//compile files('libs/google-play-services1.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/nineoldandroids-library-2.4.0.jar')
compile files('libs/Pubnub-Android-3.7.2.jar')
compile files('libs/renderscript-v8.jar')
compile files('libs/sun.misc.BASE64Decoder.jar')
compile files('libs/universal-image-loader-1.9.2.jar')
//compile files('libs/android-support-multidex.jar')
compile 'com.android.support:multidex:1.0.1'
}
please help me to solve this problem. Thank you anyway
Please change your gradle dependencies as following :
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/renderscript-v8.jar')
compile files('libs/sun.misc.BASE64Decoder.jar')
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile 'org.bouncycastle:bcprov-jdk15on:1.47'
compile 'org.apache.httpcomponents:httpcore:4.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.pubnub:pubnub-android:3.7.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.android.support:multidex:1.0.1'
Note :
In Gradle when we do not use gradle dependency and if our libs folder dependencies contains duplicate class then
java.util.zip.ZipException: duplicate entry
This exception occurs.
So Whenever you add dependencies then if possible then try maximum to use maven dependencies.
Thank you.!!
Try adding following dependencies:
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'

Categories

Resources