You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加enverify.aar后遇Duplicate类与重复文件编译错误求助

解决添加enverify.aar后的两个编译冲突问题

1. 处理OkHttp类重复错误

冲突原因:enverify.aar内部打包了OkHttp 2.7.5版本,项目中又引入了OkHttp3 5.0.0-alpha.2,两者包含重复的com.squareup.okhttp.Address类。

修改enverify.aar的依赖声明,排除其内置的OkHttp依赖:

implementation(files('libs/enverify.aar')) {
    exclude group: 'com.squareup.okhttp'
}

2. 处理TZDB.dat文件重复错误

冲突原因:项目依赖的org.threeten:threetenbp:1.3.5和enverify.aar都包含了org/threeten/bp/TZDB.dat时区数据文件,导致合并冲突。

在build.gradle(:app)的android代码块中添加打包规则,优先保留其中一份文件:

android {
    // 其他已有配置(如compileSdk、defaultConfig等)...
    
    packagingOptions {
        pickFirst 'org/threeten/bp/TZDB.dat'
    }
}

修改后的完整dependencies代码

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')
    // 修改此处,排除enverify.aar中的OkHttp依赖
    implementation(files('libs/enverify.aar')) {
        exclude group: 'com.squareup.okhttp'
    }


    //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"
}

内容的提问来源于stack exchange,提问作者Oğuzhan Örnek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 13:07:06