问题
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'
}
回答1:
Delete your build folder inside "app/"
回答2:
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
回答3:
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.
来源:https://stackoverflow.com/questions/47031968/getting-error-building-app-apptransformdexarchivewithdexmergerfordebug