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'
}
Related
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?
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"
}
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)
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'
I am trying to migrate to drive v3 api for my android app and I have followed instructions provided inhttps://github.com/gsuitedevs/android-samples/tree/master/drive/deprecation to migrate. I am getting dependency resolution errors.
I have used duplicate classes shown in log in exclude option but it haven't worked
list of my drive api dependencies
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
implementation('com.google.api-client:google-api-client-android:1.28.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev99-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
Below are the error lines shown
Duplicate class com.google.api.client.http.apache.ApacheHttpRequest found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpResponse found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpTransport found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ContentEntity found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.HttpExtensionMethod found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Looking at the error message:
found in modules google-http-client-1.29.1.jar
it seems to reference:
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
Based upon the version number. Have you tried to exclude the library from that artefact too?