Android Studio Desugar: Transform Classes with Desugar for Debug fails

Viewed 12399

My Android Studio project recently stopped building properly. I do not know what caused this issue.

Here is what I tried

  • I tried to build my project with different Android Studio versions, i.e. stable and different Canary channel versions, no change
  • I changed SDK versions around. My project built properly with SDK 26, but now it does not, also not with SDK 27
  • I swapped build tools and Gradle versions around, my project built properly with Gradle plugin 3.1.0-alpha2 and build tools version 26.0.2. I tried many
  • I used the "Clean Project", "Invalidate Caches"... functions in Android Studio uncountable times
  • I deleted my build folders
  • I switched Proguard on and off
  • I tried fixing possible library issues, but all of it did not help

I think I actually changed everything back to the settings I used successfully before and my other projects with similar settings just build fine.

Full error code:

Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {@...\app\build\intermediates\tmp\desugar_args165654356027684238}

Error:com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {@...\app\build\intermediates\tmp\desugar_args165654356027684238}
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {@...\app\build\intermediates\tmp\desugar_args165654356027684238}
Error:java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {@...\app\build\intermediates\tmp\desugar_args165654356027684238}
Error:com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {@...\app\build\intermediates\tmp\desugar_args165654356027684238}

Error:org.gradle.process.internal.ExecException: Process 'command '...\jre\bin\java.exe'' finished with non-zero exit value 1

Problem description

I have no clue what could (have) cause(d) this issue and I am clueless about what to try next, which is the reason why I am asking you for help. I hope anyone has any other help than what I could find.

I tagged Firebase because I think that the library might be the crucial point of my problem, now the problem is that it will never explain the sudden stop. I use FirebaseUI in my application and tried the old working dependencies, but also upgrading Firebase and then using this guide to match the outdated UI library. I also removed FirebaseUI, but this did neither make a successful build.

6 Answers

In my case it was the java version which was causing the issue. The error started coming when i added an SDK jar in libs and I got to know the SDK is not compatible with our java version 1.8. Solved with updated SDK jar with java 8.

I recently had the same problem with AS 3.1.4 and Gradle 4.4. I didn't understand perfectly the cause of this issue but to me it seems related to the compilation of a custom module.

I solved it importing my custom module as a jar dependency instead of "compiling" it.

In a short way:

  • In your app.gradle file and comment the line like: implementation project(path: ':XXX')
  • Open app->Open Module Settings->Dependency and add your Jar as a module dependency

Did you try to use and clear the build cache that was introduced in AS 2.3?

e.g., my gradle.properties had

android.enableBuildCache=true
android.buildCacheDir=/tmp/android-build-cache

and I had to clear /tmp/android-build-cache to fix the same Desugar error that I got.

I fixed it (and another Kotlin related issue, by just completely wiping everything Android and Gradle related from my computer and then installing everything from scratch. Whole process was a torture, so I am still keen for a quick solution. I do not want to spend hours on this again :)

In our case that was not enough ram on build machine.

Related