Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$HierarchyChangeListener
Asked Answered
S

1

5

I have tried with these solutions - Solution 1 , Solution 2

Here are my gradle dependencies.

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'
}

I have doubt on 'RxBinding design' dependency due to Coordinate layout duplicate class may be exist, so I think I need to exclude CoordinatorLayout$HierarchyChangeListener but from which dependency not sure.

So I need your help thanks in advance.

Starlight answered 6/3, 2018 at 5:31 Comment(0)
A
6

You need to add the following in your 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'
    }
}

For more information you might consider reading from this link.

Albuquerque answered 6/3, 2018 at 5:59 Comment(5)
Thank you Reaz,Yes it's work for me. Now can you please guide me why we have written this lines and how it works ?Starlight
Its like forcing all other libraries to use the exact version that you are defining here. Please see the updated answer which has a link for understanding the resolution strategy. Glad to know I could help. Welcome.Albuquerque
Thanks again Reaz, I will tell you for guiding me if I will stuck in this things.Starlight
Sure thing. Please let me know.Albuquerque
@ReazMurshed Great Answer but i want add resolutionStrategy for aar file I mean I have to add it for crashlytics. so how should I add it ?Talanta

© 2022 - 2024 — McMap. All rights reserved.