我开始使用新的更新 Android Studio 4.0.0 并遵循 在 D8 和 R8 中启用支持 java 8 库脱糖:
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
由此,我认为这很可能是新版本依赖与IDE的兼容性的bug(也许IDE更新可能会跟进解决这个问题,我不知道)。也许我们需要将其作为问题报告给谷歌,我还没有尝试过。 :D
实际上,我刚刚在寻找问题解决方案时看到你的帖子后创建了这个 Stack Overflow 帐户来分享。 :)
更新正如 R8 团队的 @sgjesse 所提到的,从
dependencies {
//noinspection GradleDependency
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
}
到
1.0.5
的更改已在 1.0.6
版本中恢复以修复此问题,因此 1.0.7
和 1.0.5
是相同的。有关更多详细信息,请参阅@sgjesse 的答案。1.0.7
我移至
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.7'
}
以删除有关过时依赖项版本的警告。 :)
附注我无法发表评论,因为我还没有 50 声望。谢谢,@sgjesse! :)
1.0.7
稳定可用
版本 coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
不适用于 AGP
1.0.6
。请使用 4.0.0
或 1.0.7
- 它们是相同的。发布版本
1.0.5
是为了解决
问题158502561,因为依赖的POM文件中存在错误,仅影响某些工具。然而,我犯了一个错误,
1.0.6
最终与Android Studio 1.0.6
不兼容,这就是4.0.0
被发布的原因。 1.0.7
和1.0.5
是相同的,1.0.7
将在稍后发布以解决依赖工件中的POM问题。dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}
时发生错误更改为
2.0.0
对我有用
1.1.5
更新于 02/2023
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
,以上错误已解决,但发生了与
2.0.1
相关的新错误。OkHttpClient
更新于 04/2023
java.lang.VerifyError: Verifier rejected class j$.util.concurrent.ConcurrentLinkedQueue
现在工作正常。
2.0.3