I start using new update Android Studio 4.0.0 和 following the enable support java 8 library desugaring in D8 和 R8:

compileOptions {
        // Flag to enable support for the new language APIs
         coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

dependencies {
    coreLibraryDesugaring 'com.和roid.tools:desugar_jdk_libs:1.0.6'
    ...
}

我最终无法构建我的应用程序,出现以下错误:

Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.

欲了解更多信息:

> Task :app:compileNoExtensionsDebugSources UP-TO-DATE

> Transform artifact desugar_jdk_libs_configuration-0.12.0.jar (com.和roid.tools:desugar_jdk_libs_configuration:0.12.0) with L8DexDesugarLibTransform
Error: Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.

> Transform artifact databinding-common-4.0.0.jar (和roidx.databinding:databinding-common:4.0.0) with DexingWithClasspathTransform
AGPBI: {"kind":"error","text":"Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.","sources":[{}],"tool":"D8"}

> Transform artifact multidex-2.0.1.aar (和roidx.multidex:multidex:2.0.1) with DexingWithClasspathTransform
Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.

AGPBI: {"kind":"error","text":"Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.","sources":[{}],"tool":"D8"}

> Transform artifact kotlin-和roid-extensions-runtime-1.3.72.jar (org.jetbrains.kotlin:kotlin-和roid-extensions-runtime:1.3.72) with DexingWithClasspathTransform
AGPBI: {"kind":"error","text":"Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.","sources":[{}],"tool":"D8"}
Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.

Do I missed any configuration here? How to fix this?

推荐答案

I encountered the same issue after I upgraded the coreLibraryDesugaring in build.gradle to com.android.tools:desugar_jdk_libs:1.0.6. My app was building fine until I did that dependency update. A suggestion popped up two hours ago when I passed by build.gradle and I just followed suit.

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.6'
}

我将依赖关系恢复到com.android.tools:desugar_jdk_libs:1.0.5,问题神奇地消失了.

dependencies {
    //noinspection GradleDependency
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
}

从这一点来看,我认为这可能是新版本的依赖项与IDE的兼容性问题(我不知道IDE更新可能会跟进以解决这个问题).也许我们需要向谷歌报告这个问题,我还没有try 过D

事实上,我刚刚创建了这个堆栈溢出账号来分享这个,因为我在搜索我的问题的解决方案时看到了你的帖子.:)

Update

As mentioned by @sgjesse from the R8 team, the changes from 1.0.5 to 1.0.6 are already reverted in the release of 1.0.7 to fix this issue, so 1.0.5 and 1.0.7 are just the same. See @sgjesse's answer for more details.

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.7'
}

I moved to 1.0.7 to remove the warning on outdated dependency version. :)

另外,我不能发表 comments ,因为我还没有50%的声誉.谢谢,@sgjesse!:)

Kotlin相关问答推荐

外键是主键的一部分,但不是索引的一部分.房间

在intellij中使用kotlin符号和floordiv

我如何测试一个可组合组件没有显示,但如果它不存在也接受?

如何在Kotlin中为接受varargs的函数添加带有默认值的新参数?

某些公共函数显然不能在类实例上访问;Klaxon示例

如何进行基于lambda/谓词的两个列表的交集?

如何注入返回通用列表的转换器?

Spring Boot Kotlin 数据类未使用 REST 控制器中的默认值初始化

内容更改后的 var 重新计算

在子类中覆盖 kotlin 运算符扩展函数

如何在 Kotlin 中使用具有继承的泛型

Kotlin 类的调用方法

变量后的Android问号

Android Studio 4.0.0 Java 8 库在 D8 和 R8 构建错误中脱糖

将 @Component.Builder 与构造函数参数一起使用

如何在 Spring WebFlux 的响应正文中流式传输二进制数据

在用Kotlin编写的Android库公共API中处理R8+JvmStatic Annotation+Lambda

如何在Kotlin中创建填充空值的通用数组?

未解决的参考 dagger 2 + kotlin + android gradle

如何将 CameraView 与 Jetpack Compose 一起使用?