多个dex文件定义了Landroid / arch / lifecycle / LiveData $ LifecycleBoundObserver;

时间:2018-03-09 22:56:23

标签: java android

运行app时显示错误

  

错误:任务执行失败   ':应用程序:transformDexArchiveWithExternalLibsDexMergerForDebug'

     
    

java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并     DEX

  

的build.gradle

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.6.2') {
        transitive = true
    }
    compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2'
    compile 'com.google.firebase:firebase-auth:11.6.0'
    compile 'com.google.firebase:firebase-messaging:11.6.0'
    compile 'com.google.firebase:firebase-messaging:11.6.0'
    compile 'com.paypal.sdk:paypal-android-sdk:2.15.3'
    compile 'com.github.TheBrownArrow:PermissionManager:1.0.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'gun0912.ted:tedbottompicker:1.0.12'
    compile 'com.akexorcist:googledirectionlibrary:1.0.5'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.android.gms:play-services-maps:11.6.0'
    compile 'com.google.android.gms:play-services-location:11.6.0'
    compile 'com.google.android.gms:play-services-places:11.6.0'
    compile 'com.google.android.gms:play-services-base:11.6.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'me.anwarshahriar:calligrapher:1.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'
    compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'

    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    implementation 'com.android.support:cardview-v7:27.0.0'
    implementation 'com.android.support:appcompat-v7:27.0.0'
    implementation 'com.android.support:design:27.0.0'
}

1 个答案:

答案 0 :(得分:2)

您需要对所有支持依赖项使用相同的版本,并且不要添加重复的依赖项。您需要对依赖项进行分组以使其更易于管理。您的依赖项应该是这样的:

dependencies {

    // Support library
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'

    // Firebase and Play service library
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    implementation 'com.google.firebase:firebase-messaging:11.6.0'
    implementation 'com.google.android.gms:play-services-maps:11.6.0'
    implementation 'com.google.android.gms:play-services-location:11.6.0'
    implementation 'com.google.android.gms:play-services-places:11.6.0'
    implementation 'com.google.firebase:firebase-database:11.6.0'

    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2'

    implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
    implementation 'com.github.TheBrownArrow:PermissionManager:1.0.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'gun0912.ted:tedbottompicker:1.0.12'
    implementation 'com.akexorcist:googledirectionlibrary:1.0.5'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.support:multidex:1.0.1'
    implementation 'me.anwarshahriar:calligrapher:1.0'
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'
    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
    implementation 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'

    implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
}