Android Studio 4.0.0 Java 8 library desugaring in D8 and R8 Build Error
Asked Answered
E

11

37

I start using new update Android Studio 4.0.0 and following the 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"
    }

and

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

I end up unable to build my application with the following error:

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

For more over:

> 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.

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

Estelaestele answered 20/6, 2020 at 5:12 Comment(0)
A
38

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'
}

I reverted the dependency back to com.android.tools:desugar_jdk_libs:1.0.5 and the issue magically disappeared.

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

From this, I think that it is likely a bug with the compatibility of the new version of the dependency with the IDE (maybe an IDE update may follow up to resolve the issue, I don't know). Maybe we need to report it as an issue to Google, I have not tried that yet. :D

Actually, I created this Stack Overflow account just now to share this after I saw your post when I searched for a solution to my problem. :)

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. :)

P.S. I can't comment because I don't have 50 reputation yet. Thanks, @sgjesse! :)

Abrams answered 20/6, 2020 at 9:32 Comment(4)
thank you. It works like magic. Hope this will be fixed for the next update, cos I don't know where to report them :D. Anyway, yes, come along to help other people here solving the problems or share your experience, it is great. πŸ‘ – Estelaestele
Yeah, I hope the issue is fixed soon. I don't know where or how to report this issue too either :D This site is great, thanks for the welcome, glad I helped! :) – Abrams
This answer is pretty old and I'm getting the same issue now after updating from 1.1.5 to 1.2.0. Could it be a bug on the R8 again? – Daffie
@Daffie build tools 7.2.0 demands version 1.1.6 – Smarmy
O
10

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' stable available

Oddball answered 5/7, 2020 at 11:3 Comment(0)
S
7

My case. Error happened when update to 2.0.0

Change to 1.1.5 works for me

coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")

Updated 02/2023

Tried to change to 2.0.1 and above error is resolve but new error related to OkHttpClient happened.

java.lang.VerifyError: Verifier rejected class j$.util.concurrent.ConcurrentLinkedQueue

Updated 04/2023

2.0.3 works fine now.

Smashandgrab answered 25/11, 2022 at 15:39 Comment(6)
You can now upgrade to 2.0.1 and above. The error is fixed – Semiannual
@Semiannual Thanks. Build succeed now but app crashed after launched. – Smashandgrab
v2.0.2 has been released. The issue is not mentioned as a fix in the change log, but it seems to be the most stable. Thanks – Semiannual
115 save my ass, 201~202 will give me Unsupported desugared library configuration version, please upgrade the D8/R8 compiler. – Goth
Yes, 2.0.2, 2.0.0 and 1.2.2 didn't solve the problem, but 1.1.5 did. – Catenate
For now(11/5/2023) 2.0.3 got a new issue ERROR:: D8: java.lang.IllegalStateException: This is not a JSON Array. org.gradle.workers.WorkerExecutionException: There were multiple failures while executing work items – Supercargo
P
6

[tl:dr] Version 1.0.6 does not work with AGP 4.0.0. Use 1.0.7 or 1.0.5 instead - they are the same.

Version 1.0.6 was released to address issue 158502561, as there was an error in a dependent POM file, only affecting certain tools. However, I made a mistake, and 1.0.6 ended up being incompatible with Android Studio 4.0.0, which is why 1.0.7 was released. 1.0.5 and 1.0.7 are identical, and 1.0.8 will be released later to address the POM issue in the dependent artifact.

Pyx answered 22/6, 2020 at 12:5 Comment(2)
is there anywhere we can find release notes for new versions of com.android.tools:desugar_jdk_libs? – Trifurcate
At the moment there is no release notes/change log for com.android.tools:desugar_jdk_libs. The challenge here is that the code in github.com/google/desugar_jdk_libs is only part of the story. The full library desugaring includes the configuration (source.corp.google.com/r8/src/library_desugar/…), which is shipped as a separate artifact (com.android.tools:desugar_jdk_libs_configuration) and a combination of AGP/D8/R8 that understands the configuration. – Pyx
U
6

Use this dependency for API 33 support. It is stable

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

Although there is a newer version 2.0.0, but I having build issues with it.

Visit this link if you are interested in version 2.0.0 google/desugar_jdk_libs

Unsuspecting answered 15/10, 2022 at 11:24 Comment(0)
A
5

I encountered the same error after updating to Android 11 and the following worked for me

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
}
Atal answered 26/10, 2020 at 10:13 Comment(0)
D
1

It seems this library has some issues with other libs versions.

At this time the latest version is 2.0.2 but I got the same error with these (Android Studio Dolphin | 2021.3.1 Patch 1, compileSdk 33).

So I found out I can use this version instead:

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'

I hope it will help others.

Donald answered 22/3, 2023 at 2:56 Comment(0)
J
1

I used the current latest version

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'

and it was enabled in one of the modules but it didn't work also until I added it also to app gradle.

  compileOptions {
    // Flag to enable support for the new language APIs
    coreLibraryDesugaringEnabled true
}

and it works fine for me

Javelin answered 5/3 at 10:18 Comment(0)
R
0

the problem is with the desugar_jdk version for me 1.1.5 works although there is the latest version 2.0.4 but it depends. see the versions of desugar_jdk. enter link description here i suggest to try any version and check which one works with your android version.

Riyadh answered 12/11, 2023 at 7:2 Comment(0)
B
0

I hade the same issue it occurred because I enabled Desugaring in build.gradle (app level)

compileOptions {
        // for flutter_local_notification
        coreLibraryDesugaringEnabled true
    }

dependencies {
    
    // for flutter_local_notification
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}

the version 1.2.2 was not compatible with my gradle I guess, so I changed it to

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

then it worked

Bondwoman answered 20/2 at 8:3 Comment(0)
C
0

For me, the desugaring library was added, but the project had other compile-time errors; however, it showed this message instead.

I tried to open the files I thought might cause compile-time errors based on my changes. After fixing the compile errors, it started building again.

Calandra answered 20/2 at 16:24 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.