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?
Related
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'
}
`
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'
}
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)
I'm currently having this error when I build my react native project using android studio. How do I fix this and remove the duplicates.
Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfo found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfoEntry found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
This seems to be caused by conflicts between Flipper and Fresco. Add this to the app level build.gradle:
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
exclude group:'com.facebook.fresco'
}
(FLIPPER_VERSION is defined in gradle.properties as 0.33.1)
I had a similar error when I upgraded my React Native project to 0.68.2.
Solved this by updating the Flipper SDK version. The flipper version was 0.33.1 and changed it to 0.99.0.
Credits
I had the same error. Removing the following code from package.json the dependencies worked for me:
"react-native-photo-view": "github:shoutem/react-native-photo-view#0ffa1481f6b6cb8663cb291b7db1d6644440584d"
I'm not really sure why but maybe because that's where the duplication is.
Updating AndroidStudio this week I was forced to add AnnotationProcessor:
(Don't even understand what for.)
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. kotlin-compiler-embeddable-1.3.11.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.11)
So I added to my app.build.gradle:
dependencies {
...
annotationProcessor "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
...
}
But now I can't get rid of the following errors:
Run tasks :app:checkDebugDuplicateClasses
> Duplicate class found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and kotlin-compiler-embeddable-1.3.11.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.11)
I don't know where org.jetbrains:annotations:13.0 is declared/imported in my gradles or settings.
How can I solve this error?
I was getting a similar Gradle error stating duplicate class found in annotations when I tried to use kotlin in some Old project. In my case, I have to remove the following dependency which was causing conflict with kotlin's annotation module.
implementation 'org.jetbrains:annotations-java5:17.0.0'
I got similar error due to some libraries using different versions of the same intellij annotation library.
I run app:dependencies and found that library com.xx.yy is using intellij.annotations.12 dependency. So I exclude that for that library only with
implemenation ("com.xx.yy:1.2.3") {
exclude group: 'com.intellij', module: 'annotations'
}
./gradlew app:dependencies
check all dependencies