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

Android构建报错:执行:app:checkDebugDuplicateClasses任务失败,存在重复类冲突

Android构建错误::app:checkDebugDuplicateClasses任务失败
  • 问题原因:执行任务:app:checkDebugDuplicateClasses失败。

执行com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable时发生故障
在模块jetified-analytics-1.0.0-runtime (io.bidmachine:analytics:1.0.0)和jetified-mediationsdk-7.6.0-runtime (com.ironsource.sdk:mediationsdk:7.6.0)中发现重复类a.a
在模块work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1)和work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)中发现重复类androidx.work.OneTimeWorkRequestKt
在模块work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1)和work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)中发现重复类androidx.work.PeriodicWorkRequestKt

解决方案

1. 统一WorkManager依赖版本

work-runtime与work-runtime-ktx版本不一致导致重复Kotlin扩展类,需将两者版本统一:

  • 在项目根build.gradle中定义统一版本:
buildscript {
    ext {
        work_version = "2.8.1"
    }
}

之后在app模块依赖中使用该版本:

implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.work:work-runtime-ktx:$work_version"
  • 或者直接强制指定work-runtime-ktx版本:
implementation("androidx.work:work-runtime-ktx:2.8.1") {
    force = true
}

2. 解决第三方SDK重复类冲突

io.bidmachine:analytics和com.ironsource.sdk:mediationsdk存在重复匿名类,可通过以下方式处理:

  • 排除其中一个SDK的冲突依赖:
// 示例:从mediationsdk中排除bidmachine的analytics模块
implementation("com.ironsource.sdk:mediationsdk:7.6.0") {
    exclude group: 'io.bidmachine', module: 'analytics'
}
  • 若排除后功能异常,尝试将其中一个SDK升级至最新稳定版本,新版本通常会修复此类依赖冲突。

内容的提问来源于stack exchange,提问作者Mohamed Lmharzi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 19:36:08