8

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.

creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
  • You're using an alpha version from the looks of things. Try installing a stable release too and see if it still gives the same issue. – Zoe Nov 14 '17 at 18:41
  • 1
    @Zoe, the first bullet point states they are using stable versions as well. –  Nov 14 '17 at 18:44
  • 1
    Post your build.gradle – Bernardo Rocha Nov 14 '17 at 19:24
  • 1
    One member of our team had this inexplicably start happening, even though several other devs on the same project were unaffected. He was on Windows at the time, and eventually discovered he could make the problem go away by downgrading play services. Unfortunately, his only permanent solution was to go back to Linux. :( – Myk Willis Nov 14 '17 at 21:54
  • @MykWillis It is actually I think my third time, but this time it does not go away. I tried downgrading already. – creativecreatorormaybenot Nov 14 '17 at 22:25
  • As it looks like a "wipe and reinstall" might be the scorched-earth solution, consider creating a new user account on this host to test if you get the same results with the same project(s) using a new account. This will at least suggest if the problem is specifically environmental. –  Nov 15 '17 at 17:53
  • @jdv As I said in my answer I did the "wipe and reinstall" solution, but now I cannot test anymore. I tried deleting everything in my users directory though and it did not help! – creativecreatorormaybenot Nov 15 '17 at 19:37
  • It is unclear to me under what circumstances things "work" and under which circumstances things do not work. Are you saying that a fresh install with a fresh user account you get the same build failure in the gradle plugin? –  Nov 15 '17 at 19:42
  • 1
    Feel your pain! Looks like this issue is not related to firebase, have a similar issue on the project without it. – Stepango Nov 19 '17 at 12:46

6 Answers6

10

For me, it happened to be the version of the Leanplum library I was using — although I was unable to surface the error through gradle, I got annoyed enough to find the Desugar sources in the bazel, build it, and then copy the command line arguments from my failing gradle build, which led me to the Leanplum jar, which appeared to have a name collision between two different obfuscated elements:

Exception in thread "main" java.lang.IllegalStateException: Already recorded as class: com/leanplum/a/x
    at com.google.common.base.Preconditions.checkState(Preconditions.java:582)
    at com.google.devtools.build.android.desugar.ClassVsInterface.addKnownInterfaces(ClassVsInterface.java:46)
    at com.google.devtools.build.android.desugar.InterfaceDesugaring.visit(InterfaceDesugaring.java:96)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:621)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)

I think this worked for me because the newer version of Desugar has better error reporting... So if like me you are unable to figure out what's going on, it's possible that

  • installing bazel (I used homebrew on the mac)
  • then building your own version of Desugar (the command I used from the root of the bazel repo was bazel build //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar),
  • and then copy & pasting the CLI arguments from your failing gradle build will lead to insight. (the command ended up looking like this: path/to/your/built/Desugar --verbose --input /Users/you/yourApp/app/build/intermediates/transforms/stackFramesFixer/envDev/debug/109.jar .... --desugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes)

I was expecting to have to add my own error logging to Desugar to catch this, but happily enough that was unnecessary.

Eric O'Connell
  • 858
  • 5
  • 14
1

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.

puprog
  • 55
  • 2
  • 10
1

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
0

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.

Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228
  • Can you please elaborate on it more? I did not fully understand what you mean, [this](https://developer.android.com/studio/build/build-cache.html) did neither help me much. I cleared every build and cache section I could find, I could not make out any change. – creativecreatorormaybenot Nov 15 '17 at 12:50
  • From the docs: By default, the Android plugin saves your cache in /.android/build-cache/. So try deleting it if you have something there. – Randy Sugianto 'Yuku' Nov 17 '17 at 03:15
0

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

creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
0

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

wilddev
  • 1,904
  • 2
  • 27
  • 45