I have android module named A. I added dependency to another module B like so: implementation project(':B')
. While the module A builds without an issue, when I try to build (and run) integration tests, I get
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)
I tried to exclude org.xmlpull.kxml
by changing my import statement to
implementation (project(':B')) {
exclude group: 'org.xmlpull.v1'
}
but the problem still exists. I have run out of ideas. Can anyone help?
Show activity on this post. Sometimes duplicate classes exception means that one of your dependencies uses implicitly the older or newer (with +) version of some library you also use in your project, To resolve this issue you may add such block of code (put your library version after 'force') to your build.gradle file (Module:app):
For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.
After deleting this folder we have to reopen our Android studio and then navigate to the Files option in the top bar and then click on Sync Project with Gradle Files to sync your project it will automatically download the new Gradle files which are required for your project. You can get to see this option on the below screenshot.
So check both places and remove duplicate entries and the clean and build APK again. Show activity on this post. Delete files with duplicate jar extensions in the libs folder. However, if there are no duplicate files and there is still a "Duplicate classes" error, look for the name in the rest of the "Duplicate classes ...."
In my case the solution was to exclude xpp3
implementation(':B') {
exclude module: 'xpp3'
}
here is a nice explanation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With