Android run error app:transformClassesWithDexForDebug - android

hi i write an app thats works on my phone (api 23,Android 6.0.1) but when i want to start the app on Geneymotion (virtual android device on api 17 )this error shows up
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.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
i write the app for that api but i dont know why this is happening
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "app.mma.introsliderproject"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.halysongoncalves:pugnotification:1.8.1'
compile 'me.tatarka.support:jobscheduler:0.1.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:support-vector-drawable:24.2.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.victor:lib:1.0.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.sd6352051:NiftyDialogEffects:v1.0.2'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.github.flavienlaurent.discrollview:library:0.0.2#aar'
compile 'com.github.alxrm:animated-clock-icon:1.0.2'
compile 'com.google.firebase:firebase-crash:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

In your application level app.gradle add the following
in dependencies,
compile 'com.android.support:multidex:1.0.2'
in defaultConfig
multiDexEnabled true
If you use your own Application class then, change it as follows,
extends Application to extends MultiDexApplication
Also add this.
#Override
protected void attachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
If you don't use any custom Application, change your AndroidManifest.xml
<application
android:name="android.support.multidex.MultiDexApplication"
... >
</application>

Add this in your app build.gradle
configurations {
compile.exclude group:'com.android.support', module: 'support-v4'
compile.exclude group:'com.android.support', module: 'support-annotations'
}

Related

java.util.zip.ZipException: duplicate entry: n.class

apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "[ MY PACKAGE ]"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
android {
useLibrary 'org.apache.http.legacy'
}
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.squareup.picasso:picasso:2.5.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.github.deano2390:android-viewbadger:1.0.0'
compile('com.jakewharton:butterknife:8.6.0') {
exclude module: 'support-compat'
}
compile project(':Library_MobilePaymentSDK')
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.aakira:expandable-layout:1.4.2#aar'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services:10.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'rongi.rotate-layout:rotate-layout:2.0.0'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.maksim88:PasswordEditText:v0.9'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jcmore2.appcrash:appcrash:1.1.0'
compile 'com.github.stfalcon:smsverifycatcher:0.2'
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile files('libs/mpaysdk-sandbox-1.0.28.jar')
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'
this gradle file works in api 21 but when i run on api 19 the following error occured.
the following error occured:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: n.class
plz help me to solve this problem.
Solution#1:
In terminal, You can execute the following command in your root project folder:
./gradlew clean
Solution#2:
If you use Android Studio, then you can do it easily, Go to Menu
Build/Clean Project
It will update old dependencies
Solution#3:
You can add the following section to your build.gradle file:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}

Unable to merge dex on Run Android App

i try run my application but suddenly arise this error
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
then i try searching and try that solution but all solution is not worked
help me :(
here is my .gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
defaultConfig {
applicationId 'com.inhatc.jh.yourplaylist'
minSdkVersion 20
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/jaudiotagger-2.2.4-SNAPSHOT.jar')
compile files('libs/glide-3.4.0.jar')
compile files('libs/google-api-services-youtube-v3-rev183-1.22.0.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
// Google Api Client library and Android extension
compile 'com.google.api-client:google-api-client-android:1.22.0'
// Change to the API you want to access:
// Below is just an example for People REST API access
compile 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
today solved my problem
i miss lib/.jar files and .gradle dependencies

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry when building APK

I know this question is asked several times. I have been trying for over 3 hours with various solutions found but none of them worked for me.
When I run the application, it works well, but when I try to build APK it is giving me the following error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzcn$zza.class
I had taken the build successfully before I added firebase for FCM notification. After FCM was added, I had dex error, so I had to add support for multidex. I am also using YouTube player jar file.
This is my Gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.sample.application"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The issue is that com.facebook.android:audience-network-sdk has dependency : play-services-ads:8.4.0 which doesn't match the 10.0.1 version
replace :
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.google.firebase:firebase-messaging:10.0.1'
with :
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group: "com.google.android.gms"
}
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

Error:Execution failed for task ':java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
It occurs this error.
The app builds success but when I get build apk, android studio show this message
This is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25'
defaultConfig {
applicationId "com.example.thewell_dev.fourscompany"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.koushikdutta.ion:ion:2.1.9'
compile 'gun0912.ted:tedpermission:1.0.2'
compile 'com.android.support:design:22.+'
compile 'com.estimote:sdk:0.13.0'
compile 'jp.wasabeef:glide-transformations:2.0.0'
compile 'com.afollestad:easyvideoplayer:0.3.0'
compile 'com.github.jrvansuita:PickImage:v2.0.0'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.mindorks:placeholderview:0.6.0'
compile 'com.tsengvn:Typekit:1.0.0'
compile 'com.github.esafirm:RxDownloader:1.0.1'
compile 'com.mlsdev.rximagepicker:library:1.1.2'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.kbeanie:image-chooser-library:1.5.2#aar'
compile 'com.kbeanie:image-chooser-library:1.5.8'
compile 'io.github.jeancsanchez.photoviewslider:photoviewslider:1.2.0'
compile 'com.nononsenseapps:filepicker:3.1.0'
compile 'com.gjiazhe:scrollparallaximageview:1.0'
compile 'com.droidninja:filepicker:1.0.8'
compile 'com.android.support:multidex:1.0.0'
}
I think external libraries have
Commons-io-1.3.2.jar
Commons-io-2.4.jar
and both have CopyUtils.class
Anyway, It can't build apk and show that message.
Please anyone help me please
There is more than one dependency you have integrated which uses Apache Commons.
just exclude them using following code in gradle.
compile('YOUR_DEPENDENCY') {
exclude module: 'commons-io'
}
Found the solution for this issue . You need to exclude common-io from your app build.gradle .
android {
configurations{
all*.exclude module: 'commons-io'
}
}
Techierj answer is correct, but it will also exclude commons-io:2.4, and in my case I needed that. So you can exclude by specific group:
compile('YOUR_DEPENDENCY') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
This will only exclude version 1.3.2 from org.apache.commons, and will mantain commons.io:commons.io:2.4

Unable to build apk file in Android Studio

I am trying to build apk but I'm unable to create it.Getting the following errors.But project running successfully.my android studio version 2.2.2
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'. >
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/common/api/zzd.class
my gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.wedding.weddingapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
configurations { all*.exclude module: 'gson-2.5' }
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://raw.githubusercontent.com/layerhq/releases-android/master/releases/" }
maven { url "https://raw.githubusercontent.com/layerhq/Atlas-Android/master/releases/" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.0'
compile 'com.layer.atlas:layer-atlas:0.3.6'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.android.support:cardview-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
You are getting
TransformException: java.util.zip.ZipException: duplicate entry:
com/google/android/gms/common/api/zzd.class
You should use latest version of Firebase
compile 'com.google.firebase:firebase-messaging:10.0.1'
and use
buildToolsVersion "25.0.1"
Thean Clean-Rebuild-Restart your IDE

Categories

Resources