mao*_*eng 11 android java-8 kotlin android-studio
我开始使用新的更新 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"
}
Run Code Online (Sandbox Code Playgroud)
和
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.6'
...
}
Run Code Online (Sandbox Code Playgroud)
我最终无法构建我的应用程序,并出现以下错误:
Unsupported desugared library configuration version, please upgrade the D8/R8 compiler.
Run Code Online (Sandbox Code Playgroud)
更多信息:
> 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.
Run Code Online (Sandbox Code Playgroud)
我在这里错过了任何配置吗?如何解决这个问题?
Roy*_*ibe 18
将coreLibraryDesugaringin升级build.gradle到com.android.tools:desugar_jdk_libs:1.0.6. 在我执行依赖项更新之前,我的应用程序构建良好。两个小时前,当我路过时突然出现一个建议build.gradle,我就照做了。
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.6'
}
Run Code Online (Sandbox Code Playgroud)
我恢复了依赖关系com.android.tools:desugar_jdk_libs:1.0.5,问题神奇地消失了。
dependencies {
//noinspection GradleDependency
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
}
Run Code Online (Sandbox Code Playgroud)
由此看来,我认为很可能是新版本的依赖与IDE的兼容性问题(也许IDE更新可能会跟进以解决问题,我不知道)。也许我们需要将其作为问题报告给 Google,我还没有尝试过。:D
实际上,我刚刚在搜索问题解决方案时看到您的帖子后创建了这个 Stack Overflow 帐户来分享这个。:)
更新
正如来自 R8 团队的 @sgjesse 所提到的,从1.0.5到的更改1.0.6已经在 的版本中恢复1.0.7以解决此问题,因此1.0.5和1.0.7完全相同。有关更多详细信息,请参阅@sgjesse 的回答。
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.7'
}
Run Code Online (Sandbox Code Playgroud)
我移到1.0.7删除对过时依赖版本的警告。:)
PS 我不能评论,因为我还没有 50 声望。谢谢,@sgjesse!:)
我的情况。更新到时发生错误2.0.0
更改为1.1.5对我有用
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
Run Code Online (Sandbox Code Playgroud)
尝试更改2.0.1为以上错误已解决,但发生了相关的新错误OkHttpClient。
java.lang.VerifyError: Verifier rejected class j$.util.concurrent.ConcurrentLinkedQueue
Run Code Online (Sandbox Code Playgroud)
2.0.3现在工作正常。
[tl:dr]版本1.0.6不适用于 AGP 4.0.0。使用1.0.7或1.0.5代替 - 它们是相同的。
1.0.6发布版本是为了解决问题 158502561,因为依赖的 POM 文件中存在错误,仅影响某些工具。然而,我犯了一个错误,1.0.6最终与 Android Studio 不兼容,这就是发布的4.0.0原因。和是相同的,稍后将发布以解决依赖工件中的 POM 问题。1.0.71.0.51.0.71.0.8
使用此依赖项来支持 API 33。很稳定
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}
Run Code Online (Sandbox Code Playgroud)
虽然有更新的版本 2.0.0,但我遇到了构建问题。
如果您对 2.0.0 版感兴趣,请访问此链接 google/desugar_jdk_libs
更新到 Android 11 后我遇到了同样的错误,以下内容对我有用
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5914 次 |
| 最近记录: |