Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 873
maohieng Avatar asked Jun 20 '20 05:06

maohieng


1 Answers

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

like image 192
Royce Pacibe Avatar answered Oct 10 '22 14:10

Royce Pacibe