Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

android - 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.

question from:https://stackoverflow.com/questions/65896074/duplicate-classes-found-in-gradle-when-trying-to-use-paging-library-3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

it looks like you are using wrong dependency. change to below line :

implementation "androidx.paging:paging-runtime:3.0.0-alpha12"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...