Search code examples
javaandroidkotlingradlegroovy

Caused by: java.lang.RuntimeException: Duplicate class com.squareup.okhttp.Address found in modules


I have a problem and I haven't been able to find a way out even though I tried some solutions on the internet.

After adding the sdk named enverify.aar to my current project, I started getting the following error.

screenshot of the error

This is the error " Caused by: java.lang.RuntimeException: Duplicate class com.squareup.okhttp.Address found in modules jetified-enverify-runtime (enverify.aar) and jetified-okhttp-2.7.5 (com.squareup.okhttp:okhttp:2.7.5) "

In addition to this error, there is also another error.

Caused by: com.android.builder.merge.DuplicateRelativeFileException: 2 files found with path 'org/threeten/bp/TZDB.dat' from inputs: screenshot of the error

My build.gradle(:app) codes are below

dependencies {
    def lifecycle_version = "2.5.1"
    def nav_version = "2.5.3"

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation project(path: ':TurkOnayWalletApi')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation "androidx.preference:preference-ktx:1.2.0"
    implementation files('libs/EnwalletSDK-debug.aar')
    implementation files('libs/enverify.aar')


    //navigation
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    //sdp
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    //chart
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    //service
    implementation 'com.google.code.gson:gson:2.9.0'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
    implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2")
    //circleindicator
    implementation 'me.relex:circleindicator:1.3.2'
    //threetenbp
    implementation 'org.threeten:threetenbp:1.3.5'
    //circleimageview
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    //android-pdf-viewer
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    //CurrencyEditText
    implementation 'com.cottacush:CurrencyEditText:0.0.10'

    // Lifecycle
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    //Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"

    implementation 'com.params.progressview:step-progress:1.0.2'
    implementation 'com.github.igortrncic.dotted-progress-bar:library:1.0.0'

    //Dependency Injection
    implementation "com.google.dagger:hilt-android:2.44"
    kapt "com.google.dagger:hilt-compiler:2.44"

}

i tried this to solve this problem but it didn't work [error] (https://i.sstatic.net/eYwtz.png)


Solution

  • After much effort, I solved my problem.

    in build.gradle(:app)

    I replaced the implementation files('libs/enverify.aar') code with this snippet of implementation project(path: ':enVerifySDK').

    I also added this code to include ':enVerifySDK' in settings.gradle.

    Of course, besides these codes, I created a folder named enVerifySDK in the root of the project and put my .aar file in this folder.

    In this way, duplicate classes have been fixed.