【问题标题】:Getting error building App: app:transformDexArchiveWithDexMergerForDebug构建应用程序时出错:app:transformDexArchiveWithDexMergerForDebug
【发布时间】:2018-04-12 10:04:05
【问题描述】:

在 android studio 中构建应用程序时出现以下错误,为什么会这样?是不是和我的proguard规则或者dexguard规则有关?

当我在 build.gradle 文件中添加“multiDexEnabled true”时,出现以下错误:

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

但是,当我在 build.gradle 文件中添加“multiDexEnabled true”时,出现以下错误:

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'
}

【问题讨论】:

  • 项目中的一个 jar 文件似乎使用的是旧版本的 google play 服务。
  • 你能给我们看看你的 build.gradle 文件吗?
  • @Patzu 你可以执行这个命令来知道依赖树 ./gradlew app:dependencies --configuration compile 然后你看看哪个依赖是重复的。

标签: android android-studio android-proguard android-studio-3.0 dexguard


【解决方案1】:

删除“app/”中的构建文件夹

【讨论】:

  • 我正在做,但是当我生成一个发布 APK 时我得到了同样的错误!
  • 你用的是哪个android studio版本?
  • Android Studio 3.5
【解决方案2】:

我看不到多索引库

implementation 'com.android.support:multidex:1.0.3'

如果您在第一种情况下将其添加到 build.gradle 文件中的依赖项中,则问题应该得到解决

注意:如果目标 SDK 设置为高于 21,则不需要任何这些

【讨论】:

    【解决方案3】:

    您的项目存在一些依赖问题,请在this answer 的帮助下检查依赖关系。你会知道哪个库有问题。

    【讨论】:

      猜你喜欢
      • 2012-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      • 1970-01-01
      • 2012-05-18
      • 2014-05-24
      相关资源
      最近更新 更多