I get the following error while building the app in android studio, why this is happening? Is it related to my proguard rules or dexguard rules?
when I add " multiDexEnabled true" in build.gradle file, I get below error:
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException:
java.nio.file.NoSuchFileException:
D:\android\app\build\intermediates\multi-dex\debug\maindexlist.txt
But, when I add " multiDexEnabled true" in build.gradle file, I get below error:
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs 'D:/DexGuard-8.0.17/lib' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.1'
classpath ':dexguard:'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'dexguard'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.c.android"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
}
buildTypes {
debug {
proguardFile 'D:/android/app/proguard-project.txt'
proguardFile 'dexguard-project.txt'
}
release {
proguardFile 'D:/android/app/proguard-project.txt'
proguardFile 'dexguard-project.txt'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
})
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.android.gms:play-services-base:11.4.2'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.android.gms:play-services-places:11.4.2'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.specyci:residemenu:1.6'
compile 'com.basgeekball:awesome-validation:2.0'
compile 'com.bahmanm:persianutils_2.10:1.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.6'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
compile 'com.google.guava:guava:23.3-android'
}
Delete your build folder inside "app/"
i can not see the multidex library
implementation 'com.android.support:multidex:1.0.3'
if you add this to dependencies in build.gradle file in your first case the problem should be solved
caution: if target SDK is set to higher than 21 there is no need for any of this
There is some dependency issue with your project, please check dependency with help of this answer. And you will know which library is being problematic.
Related
I got this error when i have tried to rebuild my project:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Despite i have added this line
multiDexEnabled true
in my app module gradle file, the error become as below.
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [C:\Users\Amine\AndroidStudioProjects\Movies\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Amine\AndroidStudioProjects\Movies\app\build\intermediates\transforms\desugar\debug\19.jar(;;;;;;**.class)] (Duplicate zip entry [19.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))
Also I have cleaned after rebuilded the project, but I have the same issue.
Below , the gradle of my app module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.0'
defaultConfig {
applicationId "com.aoutir.mohamed.movies"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField("String", "MOVIES_END_POINT", "\"https://api.themoviedb.org\"")
it.buildConfigField("String", "APPIKEY", "\my API Key")
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
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:recyclerview-v7:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.android.support:appcompat-v7:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:27.+'
compile 'com.android.support:design:27.0.1'
testCompile 'junit:junit:4.12'
}
Below the gradle file of my project module:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Thanks in advance for any help.
This is because you have duplicated support library. The source of the problem is the + usage for version. You should not use this:
compile 'com.android.support:appcompat-v7:27.+'
compile 'com.android.support:support-v4:27.+'
because gradle will use the latest version of 27 which is 27.1.0 (Take a look at Recent Support Library Revisions). Then your dependencies block will be something like this:
dependencies {
//...
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
//...
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:support-v4:27.27.1.0'
}
which is a totally different version.
But wait, you also use the following:
compile 'com.android.support:design:27.0.1'
which is a different version again. The real problem is this, support design library is implicitly using appcompat-v7 and support-v4 library. So, the above line is the same as this:
compile 'com.android.support:design:27.0.1'
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:support-v4:27.0.1'
The solutions for your problem is, you need to use same version of support library. Something like this:
dependencies {
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
// adding appcompat-v7 and support-v4 is not necessary
//when using support design.
// ...
}
I am trying run my app at emulator but I got his error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
multiDexEnabled true
applicationId "com.example.sayres.presencesystem"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
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'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.1'
}
and this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://maven.fabric.io/public' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
according some siggestion on some post I have added multiDexEnabled true to my gradle but I still got error. some developers at this site had suggested, rebuild project.I did this suggestion but I did work and I still got this error!!
what is your suggestion?
I still did this suggestion
but did not work again.
I do not have too many methods.I have just 2 activity and a few methods.my project is for learning.
I change my build.gradle to :
implementation 'com.google.firebase:firebase-database:10.2.0'
implementation 'com.google.firebase:firebase-auth:10.2.0'
implementation 'com.firebaseui:firebase-ui-auth:1.2.0'
implementation 'com.firebaseui:firebase-ui-database:1.2.0'
and
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
my problem fixed.now I can compile my project.
After updating android studio and several dependencies i now get this error message
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzeg.class
this is my gradle file
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "REMOVED_FOR_PRIVACY"
minSdkVersion 16
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'
}
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// compile 'com.firebaseui:firebase-ui:1.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:mediarouter-v7:26.0.2'
compile 'com.google.android.gms:play-services-location:11.2.0'
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-crash:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
compile 'com.google.firebase:firebase-perf:11.2.0'
compile 'com.firebaseui:firebase-ui-auth:2.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:design:26.0.2'
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:multidex:1.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I already tried Cleaning and Rebuilding the project but nothing seems to work
okay what seemed to actually work was replacing
'com.google.android.gms:play-services-location:11.2.0'
with
'com.google.android.gms:play-services:11.2.0'
Bump up your build tool version to:
buildToolsVersion "26.0.2"
And exclude Play Services from Facebook, for example
compile ('com.facebook.android:facebook-android-sdk:[4,5)'){
exclude group:"com.google.android.gms"
}
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'
I just updated my support library from 23.0.0 to 23.1.0 and now when I build the project, I get this error :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/graphics/drawable/DrawableUtils.class
Here is my app level build.gradle:
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'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23"
defaultConfig {
applicationId 'com.galleri5.android'
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 23
versionCode 6
versionName "0.6"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:23.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.3.0'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
What am I getting this error? I want to use the latest version of support library. How can I fix this issue? I read this SO thread and the solution didn't work. It gave more errors in my codebase. Also, I am not using JARs. Any help would be highly appreciated. Thanks.
I ran into the same problem in my React Native Android project, and this is what made it work for me:
cd android
./gradlew clean
You need to add the exclude group: on your support V7 like this one:
compile ('com.android.support:appcompat-v7:19.+' ) {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'com.android.support'
}