程序类型已存在:kotlinx.coroutines.experimental.EventLoopBase

dee*_*mar 7 android kotlin build.gradle kotlinx.coroutines

我在我的kotlin安卓应用程序中收到以下错误

Android问题:(3个错误)

程序类型已存在:kotlinx.coroutines.experimental.EventLoopBase消息{kind = ERROR,text =程序类型已存在:kotlinx.coroutines.experimental.EventLoopBase,sources = [未知源文件],工具名称= Optional.of(D8)}

已存在的程序类型:kotlinx.coroutines.experimental.internal.LockFreeLinkedListNode消息{kind = ERROR,text =程序类型已存在:kotlinx.coroutines.experimental.internal.LockFreeLinkedListNode,sources = [未知来源文件],工具名称= Optional.of(D8)}

程序类型已存在:kotlinx.coroutines.experimental.internal.LockFreeMPSCQueueCore消息{kind = ERROR,text =程序类型已存在:kotlinx.coroutines.experimental.internal.LockFreeMPSCQueueCore, sources = [未知源文件],工具名称= Optional.of(D8)}

Java编译器:(4个错误)

引起:com.android.builder.dexing.DexArchiveBuilderException:无法处理/home/deepak/.gradle/caches /modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-corouti nes-core/0.25.0/5664ba2d20c6dcc88c912cc9666baa7f03203bcd/kotlinx-coroutines-core-0.25.0.jar

引起:com.android.builder.dexing.DexArchiveBuilderException:dexing时出错.

引起:com.android.tools.r8.CompilationFailedException:编译未能完成

引起:com.android.tools.r8.utils.AbortException

下面是我的依赖和kotlin实验协同程序

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

implementation 'org.jetbrains.anko:anko:0.10.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.0'
implementation 'com.android.support:design:28.0.0-rc01'
}

kotlin {
    experimental {
        coroutines "enable"
    }
}
Run Code Online (Sandbox Code Playgroud)

qww*_*sad 5

这是0.25.0中引入的错误kotlinx.coroutines.

版本0.25.0以多版本JAR的形式发布,这样的JAR打破了除最新alpha版本之外的所有Android工具.此更改已在版本0.25.3中还原,因此更新kotlinx.coroutines版本和使缓存无效就足以解决问题.


dee*_*mar 1

最后,经过大量的组合和研究,我找到了解决方案,但它肯定不是永久的解决方案。

我发现同时使用两个依赖项Kotlin Coroutineandroidx依赖项会导致问题所以,我删除了它们,现在我使用 android 依赖项而不是 androidx。现在,我的依赖项如下所示:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'org.jetbrains.anko:anko:0.10.5'
    implementation 'org.jetbrains.anko:anko-design:0.10.5'
    implementation 'com.android.support:design:28.0.0-rc01'
}
kotlin {
    experimental {
        coroutines "enable"
    }
}
Run Code Online (Sandbox Code Playgroud)

感谢@Sayem的帮助

快乐编码!