当我构建我的应用程序时,我有4条错误信息;它们是在我添加一个新的依赖项时出现的(de.westnordost:osmapi-notes:1.3)。这些信息都是相似的:
Duplicate class org.xmlpull.v1.XmlPullParser found in modules jetified-kxml2-2.3.0 (net.sf.kxml:kxml2:2.3.0) and jetified-xmlpull-1.1.3.1 (xmlpull:xmlpull:1.1.3.1)
Duplicate class org.xmlpull.v1.XmlPullParserException found in modules jetified-kxml2-2.3.0 (net.sf.kxml:kxml2:2.3.0) and jetified-xmlpull-1.1.3.1 (xmlpull:xmlpull:1.1.3.1)
Duplicate class org.xmlpull.v1.XmlPullParserFactory found in modules jetified-kxml2-2.3.0 (net.sf.kxml:kxml2:2.3.0) and jetified-xmlpull-1.1.3.1 (xmlpull:xmlpull:1.1.3.1)
Duplicate class org.xmlpull.v1.XmlSerializer found in modules jetified-kxml2-2.3.0 (net.sf.kxml:kxml2:2.3.0) and jetified-xmlpull-1.1.3.1 (xmlpull:xmlpull:1.1.3.1)
这些依赖关系是:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.navigation:navigation-fragment:2.3.2'
implementation 'androidx.navigation:navigation-ui:2.3.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'org.osmdroid:osmdroid-android:6.1.8'
implementation 'org.osmdroid:osmdroid-wms:6.1.8'
implementation 'org.osmdroid:osmdroid-mapsforge:6.1.8'
implementation 'org.osmdroid:osmdroid-geopackage:6.1.8'
implementation 'org.osmdroid:osmdroid-third-party:6.0.1'
implementation 'com.github.MKergall:osmbonuspack:6.6.0'
implementation 'de.westnordost:osmapi-notes:1.3'
}
我看过这线程,它对找到解决方案有很大帮助,但我无法计算出要排除的正确组和模块。我试过这三种方法:
configurations {
/* runtime.exclude group: "org.xmlpull" , module: "xmlpull"*/
/* runtime.exclude group: "net.sf.kxml" , module: "kxml2"*/
runtime.exclude group: "org.xmlpull" , module: "jetified-xmlpull-1.1.3.1"
}
但它们最终都有相同的4组错误。那么,我需要使用的正确语法/组/模块是什么?
发布于 2021-01-19 23:57:47
通常,人们都会排除这一点(这似乎就足够了):
implementation ("de.westnordost:osmapi-notes:1.3") {
exclude group: "xmlpull", module: "xmlpull"
}
org.osmdroid:osmdroid-mapsforge:6.1.8
也有这些类,但可能比xmlpull
有更多的代码。由于它们没有相同的包名,所以最终(如果排除不能工作)可以使用分级阴影插件重新定位其中的一个包,并通过通配符org.xmlpull.v1.*
排除其中一个包。
发布于 2021-01-19 23:38:06
试着用这种方式排除
implementation('de.westnordost:osmapi-notes:1.3') {
exclude group: 'net.sf.kxml', module: 'kxml2'
exclude group: 'xmlpull', module: 'xmlpull'
exclude group: 'xpp3', module: 'xpp3'
}
https://stackoverflow.com/questions/65800564
复制相似问题