I am unable to build for android due to desugar error


#1

Hi. I’m trying to build for android and I’m getting this error. Unable to find a solution after hours of searching the web.

ionic cordova build android

* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
> 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 {--input /Users/jami/repos/firebase/myapp/platforms/android/app/build/intermediates/transforms/stackFram
...
...
...
BUILD FAILED in 8s
36 actionable tasks: 33 executed, 3 up-to-date
Error: /Users/jami/repos/firebase/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Exception in thread "main" java.lang.IllegalArgumentException
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
        at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:471)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)

I have installed android studio.
I have this in my ~/.bash_profile (reloaded with source):

    1 export ANDROID_HOME=~/Library/Android/sdk/
    2 export PATH=${PATH}:~/Library/Android/sdk/platform-tools/:~/Library/Android/sdk/tools/:~/Library/Android/sdk/tools/bin/
    3 export JAVA_HOME=/Library/Java/Home

java -version

java version "1.8.0_172"

sdkmanager --list

Warning: File /Users/jami/.android/repositories.cfg could not be loaded.
Installed packages:=====================] 100% Computing updates...
  Path                                                                              | Version | Description                                     | Location
  -------                                                                           | ------- | -------                                         | -------
  build-tools;23.0.3                                                                | 23.0.3  | Android SDK Build-Tools 23.0.3                  | build-tools/23.0.3/
  build-tools;26.0.2                                                                | 26.0.2  | Android SDK Build-Tools 26.0.2                  | build-tools/26.0.2/
  emulator                                                                          | 27.1.12 | Android Emulator                                | emulator/
  extras;android;m2repository                                                       | 47.0.0  | Android Support Repository                      | extras/android/m2repository/
  extras;google;auto                                                                | 1.1     | Android Auto Desktop Head Unit emulator         | extras/google/auto/
  extras;google;m2repository                                                        | 58      | Google Repository                               | extras/google/m2repository/
  extras;google;market_apk_expansion                                                | 1       | Google Play APK Expansion library               | extras/google/market_apk_expansion/
  extras;google;simulators                                                          | 1       | Android Auto API Simulators                     | extras/google/simulators/
  extras;intel;Hardware_Accelerated_Execution_Manager                               | 6.2.1   | Intel x86 Emulator Accelerator (HAXM installer) | extras/intel/Hardware_Accelerated_Execution_Manager/
  extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1       | Solver for ConstraintLayout 1.0.2               | extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/
  extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2        | 1       | ConstraintLayout for Android 1.0.2              | extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/
  patcher;v4                                                                        | 1       | SDK Patch Applier v4                            | patcher/v4/
  platform-tools                                                                    | 27.0.1  | Android SDK Platform-Tools                      | platform-tools/
  platforms;android-22                                                              | 2       | Android SDK Platform 22                         | platforms/android-22/
  platforms;android-23                                                              | 3       | Android SDK Platform 23                         | platforms/android-23/
  platforms;android-26                                                              | 2       | Android SDK Platform 26                         | platforms/android-26/
  sources;android-23                                                                | 1       | Sources for Android 23                          | sources/android-23/
  tools                                                                             | 26.1.1  | Android SDK Tools                               | tools/

ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 browser 5.0.3 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v8.9.1
    npm               : 5.7.1
    OS                : macOS High Sierra
    Xcode             : Xcode 9.3 Build version 9E145

Environment Variables:

    ANDROID_HOME : /Users/jami/Library/Android/sdk/

Misc:

    backend : pro

Please help, this is blocking my app’s release.


#3

See: https://stackoverflow.com/questions/45833937/execution-failed-for-task-apptransformclasseswithdesugarfordebug-error-on-andro


#4

same problem here, but I have solved this problem.
see watch this video tut:
link - AdMobAdsFree Plugin Error - Execution failed for task : 'app.transformClassesWithDesugarForDebug


#5

Solution cordova clean android

Source Stack Overflow


#6

@ThonyFD12 tq so much bro , u saved my time


I get an error when building my Ionic app, that I didn't used to get
#7

This worked perfectly for me. Note: just “cordova clean android” in this case, you can’t use “ionic cordova” or “ionic cordova platform”.


#8

Thanks, this worked for me.


#9

You are super. Solved my problem.