【问题标题】:Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$HierarchyChangeListener错误:com.android.dex.DexException:多个 dex 文件定义 Landroid/support/design/widget/CoordinatorLayout$HierarchyChangeListener
【发布时间】:2018-03-06 14:07:05
【问题描述】:

我已经尝试过这些解决方案 - Solution 1 , Solution 2

这是我的 gradle 依赖项。

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    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'
    //Recycleview
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    //Butterknife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    //SDP
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    //OkHttp
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    //RxJava and RxAndroid
    implementation 'io.reactivex.rxjava2:rxjava:2.0.6'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.ashdavies.rx:rx-firebase:1.3.3'
    //RxBinding
    implementation 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'
    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
    //Glide
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    //GSON
    implementation 'com.google.code.gson:gson:2.2.4'
    //Image Crop Library
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    //Dagger Android
    implementation 'com.google.dagger:dagger:2.13'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'
    implementation 'com.google.dagger:dagger-android-support:2.13'
    //Only applying android dagger.
    implementation 'com.android.support:cardview-v7:27.0.2'
    implementation 'com.android.support:multidex:1.0.2'
}

由于可能存在坐标布局重复类,我对“RxBinding 设计”依赖存在疑问,所以我认为我需要排除 CoordinatorLayout$HierarchyChangeListener 但不确定是哪个依赖。

所以我需要你的帮助提前谢谢。

【问题讨论】:

    标签: android android-coordinatorlayout android-multidex rx-binding


    【解决方案1】:

    您需要在build.gradle 中添加以下内容

    configurations.all {
        resolutionStrategy {
            force 'com.android.support:design:27.0.2'
            force 'com.android.support:support-v4:27.0.2'
            force 'com.android.support:appcompat-v7:27.0.2'
        }
    }
    

    有关更多信息,您可以考虑阅读this link

    【讨论】:

    • 谢谢 Reaz,是的,它对我有用。现在你能指导我为什么要写这行代码以及它是如何工作的吗?
    • 这就像强制所有其他库使用您在此处定义的确切版本。请参阅更新的答案,其中包含了解解决策略的链接。很高兴知道我能帮上忙。欢迎。
    • 再次感谢 Reaz,如果我会坚持下去,我会告诉你指导我。
    • 当然可以。请告诉我。
    • @ReazMurshed 很好的答案,但我想为 aar 文件添加 resolutionStrategy 我的意思是我必须为 crashlytics 添加它。那我应该怎么添加呢?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2015-06-30
    • 1970-01-01
    • 2014-06-10
    • 1970-01-01
    相关资源
    最近更新 更多