Gradle Android "Duplicate class foo found in module bar" 错误
Gradle Android "Duplicate class foo found in module bar" error
我有 android 个名为 A 的模块。我像这样向另一个模块 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
implementation(':B') {
exclude module: 'xpp3'
}
我有 android 个名为 A 的模块。我像这样向另一个模块 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
implementation(':B') {
exclude module: 'xpp3'
}