我在 Android 应用程序上集成新库时遇到了问题。
当我尝试
implementation 'br.com.stone:stone-sdk:3.8.2'
在 Gradle(应用程序模块)和同步项目时,android 显示了一个新问题
Duplicate class org.xmlpull.v1.XmlPullParser found in modules jetified-ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar (ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar) and jetified-xpp3_min-1.1.4c.jar (xpp3:xpp3_min:1.1.4c)
Duplicate class org.xmlpull.v1.XmlPullParserException found in modules jetified-ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar (ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar) and jetified-xpp3_min-1.1.4c.jar (xpp3:xpp3_min:1.1.4c)
也许实现文件('libs/ksoap2-android- assembly-3.0.0-jar-with-dependency.jar')已经具有相同的类。
谁能帮我解决这个问题吗?
我发布这个答案以供参考,基于https://github.com/flutter/flutter/issues/59341。您需要做的就是在 app/build.gradle 中添加 3 项:
shrinkResources false
minifyEnabled false
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
}
implementation 'xmlpull:xmlpull:1.1.3.4d_b4_min'
PS:我使用此解决方案修复了类似的问题(只需将第 2 项中的“xpp3”替换为“xmlpull”):
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
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.4d_b4_min (xmlpull:xmlpull:1.1.3.4d_b4_min)
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.4d_b4_min (xmlpull:xmlpull:1.1.3.4d_b4_min)
有效的解决方案是将这部分写入 app/build.gradle
configurations.all {
exclude group: 'xmlpull', module: 'xmlpull'
exclude group: 'xpp3', module: 'xpp3_min'
}