引起原因:com.android.dex.DexException:多个dex文件定义了Landroid / arch / core / internal / SafeIterableMap $ ListIterator;

时间:2018-10-04 06:06:56

标签: android android-studio gradle uber-api

  

原因:com.android.dex.DexException:多个dex文件定义了Landroid / arch / core / internal / SafeIterableMap $ ListIterator;

添加Uber SDK依赖项gradle后出现此错误。

   compile 'com.uber.sdk:rides-android:0.9.1'
  compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':material_search')

    compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-v13:$rootProject.supportLibraryVersion"
    compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.supportLibraryVersion"

    implementation("android.arch.persistence.room:runtime:$archRoomVersion") {
        exclude group: 'com.android.support'
    }
    annotationProcessor("android.arch.persistence.room:compiler:$archRoomVersion") {
        exclude group: 'com.android.support'
    }

    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true
    }
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
    compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile "com.google.android.gms:play-services-location:$firebaseVersion"
    compile "com.google.firebase:firebase-messaging:$firebaseVersion"
    compile 'com.pixplicity.htmlcompat:library:1.0.0'
    compile 'com.facebook.fresco:fresco:1.5.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.uber.sdk:rides-android:0.9.1'



 minSdkVersion = 17
    targetSdkVersion = 26
    compileSdkVersion = 26
    buildToolsVersion = '26.0.2'
    supportLibraryVersion = '26.1.0'
    retrofitVersion = '2.3.0'
    firebaseVersion = '11.4.0'
    archRoomVersion = '1.0.0-alpha1'

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

尝试在multiDexEnabled = true文件中添加build.gradle并创建一个应用程序类。在attachBaseContext方法中,调用MultiDex.install(this)。并且不要忘记在清单文件中声明应用程序类。请参阅此https://developer.android.com/studio/build/multidex。谢谢。