我正在尝试使用分页库3来实现分页。但是,在完成所有必要的步骤(寻呼源、流等)之后,我无法运行我的项目。这是我的依赖项列表:
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)这不是完整的堆栈跟踪。我的一些依赖关系:
// 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此外,我尝试以这种方式排除一些依赖关系:
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12' {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'但它会产生以下错误:
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.我试着运行一个从raywenderlich教程下载的示例项目,它在相同的依赖项下运行良好。迁移到分页v2解决了这个问题,但是我想在更新的版本中使用新的功能。
发布于 2021-02-08 20:57:13
您应该像这样编写依赖项,以避免使用下面所述的模块和组。您还可以通过检查错误消息并将其粘贴到这里来检查带有重复类的模块和/或包。
implementation ('androidx.paging:paging-runtime:3.0.0-alpha12') {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}发布于 2021-02-06 18:40:56
看起来您使用的是错误的依赖关系。改为下面一行:
implementation "androidx.paging:paging-runtime:3.0.0-alpha12"发布于 2021-06-13 03:16:34
顺便说一句,我不得不使用稳定版本的分页。对我来说,下面的解决方案奏效了。我希望这个解决方案在某些情况下也会有所帮助。
implementation ('androidx.paging:paging-runtime-ktx:3.0.0') {
exclude group: 'org.jetbrains.kotlinx'
}https://stackoverflow.com/questions/65896074
复制相似问题