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

我尝试通过将import语句更改为排除org.xmlpull.kxml
    implementation (project(':B')) {
        exclude group: 'org.xmlpull.v1'
    }

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

最佳答案

就我而言,解决方案是排除xpp3
implementation(':B') { exclude module: 'xpp3' }
here is a nice explanation

08-05 21:06