gpt4 book ai didi

java - Gradle Android "Duplicate class foo found in module bar"错误

转载 作者:太空狗 更新时间:2023-10-29 14:34:57 24 4
gpt4 key购买 nike

我有一个名为 A 的 android 模块。我像这样向另一个模块 B 添加了依赖项:implementation project(':B')。虽然模块 A 构建没有问题,但当我尝试构建(和运行)集成测试时,我得到了

Duplicate class org.xmlpull.v1.XmlPullParser found in modules kxml2-2.3.0.jar (net.sf.kxml:kxml2:2.3.0) and xpp3-1.1.3.3.jar (xpp3:xpp3:1.1.3.3)
Duplicate class org.xmlpull.v1.XmlPullParserException found in modules kxml2-2.3.0.jar (net.sf.kxml:kxml2:2.3.0) and xpp3-1.1.3.3.jar (xpp3:xpp3:1.1.3.3)
Duplicate class org.xmlpull.v1.XmlPullParserFactory found in modules kxml2-2.3.0.jar (net.sf.kxml:kxml2:2.3.0) and xpp3-1.1.3.3.jar (xpp3:xpp3:1.1.3.3)
Duplicate class org.xmlpull.v1.XmlSerializer found in modules kxml2-2.3.0.jar (net.sf.kxml:kxml2:2.3.0) and xpp3-1.1.3.3.jar (xpp3:xpp3:1.1.3.3)

我试图通过将导入语句更改为

来排除 org.xmlpull.kxml
    implementation (project(':B')) {
exclude group: 'org.xmlpull.v1'
}

但问题依然存在。我已经没有想法了。谁能帮忙?

最佳答案

在我的例子中,解决方案是排除 xpp3

实现(':B'){
排除模块:'xpp3'
}

here is a nice explanation

关于java - Gradle Android "Duplicate class foo found in module bar"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57850234/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com