Gradle Android“在模块栏中找到重复的类foo”错误

时间:2019-09-09 08:21:00

标签: java android gradle android-module

我有一个名为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'
    }

,但问题仍然存在。我的想法已经用完了。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

在我的情况下,解决方案是排除xpp3

implementation(':B') { exclude module: 'xpp3' }

here is a nice explanation