Duplicate class org.xmlpull.v1.XmlPullParser Android - android

i have a hudge problem while integrating a new library on Android App.
When i tried to implementation 'br.com.stone:stone-sdk:3.8.2' on Gradle (app module) and sync project, android shows a new issue
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)
Perhaps implementation files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar') has already the same Class.
Can anynone help me solving this problem?

I'm posting this answer for reference, based on https://github.com/flutter/flutter/issues/59341. All you need to do is to add 3 items in app/build.gradle:
shrinkResources false
minifyEnabled false
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
}
implementation 'xmlpull:xmlpull:1.1.3.4d_b4_min'
PS: I used this solution fix a similar issue (just replaced "xpp3" with "xmlpull" in item #2):
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)

Related

Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules

Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-20.1.5-runtime (com.google.firebase:firebase-iid:20.1.5) and jetified-firebase-messaging-23.1.1-runtime (com.google.firebase:firebase-messaging:23.1.1)
I'm trying to integrate the Carrot Quest library and I'm facing a dependency conflict problem.
I tried to do exclude group, but without success
`
implementation ('io.carrotquest:android-sdk:1.0.60-commonRelease') {
exclude group: 'com.google.firebase'
}
`

Gradle duplicated class

In my Android app, I added a new dependency in the Gradle file. It turned out that this dependency is conflicting with one of the other dependencies in the project. When I'm trying to build the app I get the following error:
Duplicate class android.content.pm.IPackageStatsObserver found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub$Proxy found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
As the log shows the problem is 3 duplicated classes that are present in both dependencies. To solve this I tried to exclude the android.content.pm package from one or the other dependency like that:
implementation ('com.dependency:framework:1.12.0') {
exclude group: 'android.content.pm'
}
or like that:
implementation('com.myapp.androidcommon:androidcommon-debug:1.2.2') {
exclude group: 'android.content.pm'
}
but I keep getting the same error. Any idea how to solve this issue?

Duplicate class com.google.android.flexbox - Android Admob

I am using admob and facebook for ads in my app and its done but I want to check it so i have added Mediation Test Suite depnedancy
implementation 'com.google.android.ads:mediation-test-suite:2.0.0'
And the app could not build it shows
Duplicate class com.google.android.flexbox.AlignContent found in modules jetified-flexbox-1.1.1-runtime (com.google.android:flexbox:1.1.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.AlignItems found in modules jetified-flexbox-1.1.1-runtime (com.google.android:flexbox:1.1.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
And many more Duplicate Class of Flexbox
my admob version
implementation 'com.google.android.gms:play-services-ads:20.4.0'
The package name is wrong.
com.google.android:flexbox:1.1.1
Here is the correct one. ↓
implementation ('com.google.android.ads:mediation-test-suite:2.0.0') {
exclude group: "com.google.android", module: "flexbox"
}
It worked for me.
Exclude the flexbox module which is causing the conflict like this...
implementation ('com.google.android.ads:mediation-test-suite:2.0.0') {
exclude group: "com.google.android.flexbox", module: "flexbox"
}

Duplicate classes found in Gradle when trying to use Paging Library 3

I am trying to implement paging using Paging Library 3. However, I cannot run my project after doing all the necessary steps (paging source, flow, and etc). This is the list of my dependencies:
Duplicate class kotlinx.coroutines.AbstractCoroutine found in modules jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.Active found in modules jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.AwaitAll found in modules jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.AwaitAll$AwaitAllNode found in modules jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.AwaitAll$DisposeHandlersOnCancel found in modules jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
It's not the full stack trace. Some of my dependencies:
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
// Paging
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12'
// Image Compressor
implementation 'id.zelory:compressor:3.0.0' // this lib also uses coroutines
Also, I've tried excluding some dependencies this way:
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12' {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
But it produces the following error:
A problem occurred evaluating project ':app'.
> Could not find method androidx.paging:paging-runtime-ktx:3.0.0-alpha12() for arguments [build_cmaofa0fil3wjmmcunq4oc9m5$_run_closure2$_closure8#2e68c056] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I tried running an example project downloaded from a raywenderlich tutorial and it runs fine with the same dependencies. Migrating to Paging v2 resolves the issue but I would like to use the new functionality in the updated version.
You should write the dependency like this to avoid using from the below-stated module and group. You can also check for the module and/or package with the duplicate classes by checking the error message and pasting it here.
implementation ('androidx.paging:paging-runtime:3.0.0-alpha12') {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}
it looks like you are using wrong dependency. change to below line :
implementation "androidx.paging:paging-runtime:3.0.0-alpha12"
BTW, I had to use a stable version of paging.
For me, the below solution worked. I hope this solution also might be helpful in some cases.
implementation ('androidx.paging:paging-runtime-ktx:3.0.0') {
exclude group: 'org.jetbrains.kotlinx'
}

Different libraries depend on the same library and will prompt "Duplicate class" during compilation. How to exclude this duplicate class?

error like this:
Duplicate class com.google.android.exoplayer2.ui.AspectRatioFrameLayout found in modules jetified-VideoPlayModule-Lite-2.3.61-runtime.jar (com.ycjiang:VideoPlayModule-Lite:2.3.61) and jetified-exoplayer-ui-2.12.1-runtime.jar (com.google.android.exoplayer:exoplayer-ui:2.12.1)
Duplicate class com.google.android.exoplayer2.ui.AspectRatioFrameLayout$1 found in modules jetified-VideoPlayModule-Lite-2.3.61-runtime.jar (com.ycjiang:VideoPlayModule-Lite:2.3.61) and jetified-exoplayer-ui-2.12.1-runtime.jar (com.google.android.exoplayer:exoplayer-ui:2.12.1)
gradle:
implementation 'com.google.android.exoplayer:exoplayer:2.12.1'
implementation 'com.ycjiang:VideoPlayModule:2.3.61'

Categories

Resources