gradle - 错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'执行失败。> com.android.builder

标签 gradle

Blockquote



错误:任务执行失败:app:transformDexArchiveWithExternalLibsDexMergerForDebug
com.android.builder.dexing.DexArchiveMergerException:无法合并dex

Blockquote



这是 build.gradle 文件
    dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.google.firebase:firebase-crash:11.2.2'
implementation 'com.google.firebase:firebase-ads:11.2.2'
implementation 'com.google.firebase:firebase-config:11.2.2'
implementation 'com.google.code.findbugs:jsr305:2.0.1'
implementation 'com.onesignal:OneSignal:3.7.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}apply plugin: 'com.google.gms.google-services'

构建gradle(项目):
buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:3.1.0'
}
}

  allprojects {
     repositories {
       google()
       jcenter()
     }
  }
task clean(type: Delete) {
delete rootProject.buildDir
}

从Gradle控制台

Error:Error converting bytecode to dex:

Cause: com.android.dex.DexException: Multiple dex files define

Lcom/google/android/gms/internal/zzcdn;

最佳答案

我发现这两个库存在库冲突:

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.onesignal:OneSignal:3.7.1'

所以我基本上删除了
implementation 'com.android.support:appcompat-v7:26.1.0'

因为我要使用onesignal及其库功能.... :)

关于gradle - 错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'执行失败。> com.android.builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48239308/

相关文章:

android - 如何禁用 build.gradle 中的任务

java - 构建我的 Android ReactJs Native 应用程序时遇到问题

flutter - 任务 ':app:lintVitalRelease' 执行失败。 flutter

android - 集成TensorFlow和DJI SDK时无法合并dex

android - 由于 Android Studio 冲突而忽略了依赖项

gradle - 具有非标准文件夹层次结构的多个项目Gradle构建

java - gradle:通过(文件)循环调用java插件

java - 从C++到Java-什么是Gradle

android - 如何在 gradle.build 脚本中引用 aar 文件?

gradle - 如何在intellij中打开带有子项目的项目以使intellisense工作