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

时间:2018-01-13 11:13:26

标签: gradle

  

块引用

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

  

块引用

以下是 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'

build gradle(project):

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;

1 个答案:

答案 0 :(得分:0)

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

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'

因为我打算使用信号和它的库功能......:)