android - com.google.gson.ExclusionStrategy 类型定义了多次

标签 android gradle build build.gradle contentful

当我尝试向我的应用程序的 gradle 文件中添加 Contentful 的实现时出现此错误

Type com.google.gson.ExclusionStrategy is defined multiple times

看起来我的中间 dex 文件中的某些内容正在发生。这是完整的错误:
Error: /Users/ceddings/StudioProjects/r15-android-rms-kiosk-launcher/kiosk/build/intermediates/mixed_scope_dex_archive/debug/out/2fcf9ca3ebe4bba6e5de15039706dbd823b837def40fd130c6d32dbf72d7d3fe_1.jar:classes.dex, Type com.google.gson.ExclusionStrategy is defined multiple times: /Users/ceddings/StudioProjects/r15-android-rms-kiosk-launcher/kiosk/build/intermediates/mixed_scope_dex_archive/debug/out/2fcf9ca3ebe4bba6e5de15039706dbd823b837def40fd130c6d32dbf72d7d3fe_1.jar:classes.dex, /Users/ceddings/StudioProjects/r15-android-rms-kiosk-launcher/kiosk/build/intermediates/mixed_scope_dex_archive/debug/out/1c3715710bef6d11c4bd58c73e056adcb809f2dac72c25d60ee538a9010444f0_1.jar:classes.dex

下面是我的 gradle 文件。我该如何解决这个问题?
dependencies {
implementation project(':sharedcore')
implementation project(':data')
implementation project(':scanner')

implementation deps.kotlin.kotlin_jre
implementation deps.android.app_compat
implementation deps.android.material
implementation deps.android.constraint_layout
implementation deps.logging.timber
implementation deps.retrofit.retrofit
implementation deps.retrofit.retrofit_moshi
implementation deps.moshi.moshi
implementation deps.koin.koin_viewmodel
implementation deps.kotlin.coroutines_core
implementation deps.kotlin.coroutines_android
implementation(deps.auth.adal) {
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.google.code.gson', module: 'gson'
}
implementation deps.ms_app_center.analytics
implementation deps.ms_app_center.crashes
implementation deps.viewpager2.viewpager2
implementation deps.contentful.contentful

// Testing
testImplementation deps.testing.junit
testImplementation deps.testing.test_core
testImplementation deps.testing.test_runner
testImplementation deps.testing.test_rules
testImplementation deps.testing.ext_junit
testImplementation deps.testing.mockk
testImplementation deps.testing.mockk_android
testImplementation deps.testing.robolectric
testImplementation deps.testing.espresso_core
testImplementation deps.testing.espresso_intents

}

最佳答案

我也遇到了同样的问题,我猜你应该删除build.gradle文件中的"exclude group: 'com.google.code.gson', module: 'gson',然后查看项目根目录下的settings.gradle文件目录类似并删除文件....

关于android - com.google.gson.ExclusionStrategy 类型定义了多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61022373/

相关文章:

android - 我可以在不将应用发布到 Alpha 或 Beta 版的情况下测试应用内结算吗?

java - 来自 2 个与用户位置配合使用的 AsyncTask,只有一个适用于 Java 和 Android

android - 预定同步适配器每 30 秒运行一次

Gradle、Android、Jacoco 和 JUnit5

java - 即使在新应用程序中构建 gradle 也会失败

java - 如何跳过多 Maven 模块中的生命周期阶段

android - build.phonegap.com 是否有任何开源替代品?

java - 无限用户Wifi AP android模式(无ROOT权限)

java - Android studio 中的 Android 注解 - 无法访问 Activity_?

android - 错误 :(6, 0) 未找到 Gradle DSL 方法: 'google()'