我开始使用新的更新Android Studio 4.0.0,并按照enable support java 8 library desugaring in D8 and 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.android.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.android.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 (androidx.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 (androidx.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-android-extensions-runtime-1.3.72.jar (org.jetbrains.kotlin:kotlin-android-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.

我在这里错过任何配置吗?如何解决这个问题?

最佳答案

coreLibraryDesugaring中的build.gradle升级为com.android.tools:desugar_jdk_libs:1.0.6后,遇到了相同的问题。在我进行依赖更新之前,我的应用程序运行良好。两个小时前,当我通过build.gradle时出现了一个建议,我也紧随其后。

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更新来解决该问题)。也许我们需要将其作为问题报告给Google,但我还没有尝试过。 :D
实际上,我刚刚创建了这个Stack Overflow帐户,以便在寻找问题的解决方案时看到您的帖子后分享。 :)
更新
正如R8小组的@sgjesse所提到的那样,从1.0.51.0.6的更改已在1.0.7发行版中恢复,以解决此问题,因此1.0.51.0.7相同。有关更多详细信息,请参见@sgjesse的答案。
dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.7'
}
我移至1.0.7来删除有关过时的依赖版本的警告。 :)
P.S.我没有评论,因为我还没有50声望。谢谢,@ sgjesse! :)

09-30 15:03
查看更多