gonephishing
gonephishing

Reputation: 1416

Getting app:transformClassesWithDesugarForDebug Exception while compiling project

Gradle build is failing with following app's build.gradle config:

android{
compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.sample.demo"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions"
//                abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
                abiFilters 'armeabi-v7a'
            }
        }

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['src/main/jniLibs']
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Below is the error log for the same:

:app:transformClassesWithDesugarForDebug
Exception in thread "main" java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at com.google.devtools.build.android.desugar.CoreLibraryRewriter.reader(CoreLibraryRewriter.java:44)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:388)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)

I have tried most of the other solutions like:

  1. Delete build folder, kill java from Activity Monitor and restart android studio - Doesn't work (I even restarted the system)
  2. Matching gms-play-services version and firebaseAuth version - 11.6.0
  3. Enabling multidex support - Added multiDexEnabled true to android defaultConfig
  4. Specifying compile option as java 8 - Added as shown above.

In all, these are popular answers around for this exception on SO and none of them have worked for me. I could have posted the complete log with stacktrace but SO thinks its more code than details and thus not allowing me to do the same. Though let me know if anything else is required and I will make alternate arrangements.

Upvotes: 3

Views: 1181

Answers (1)

Holger
Holger

Reputation: 298459

The only place where org.objectweb.asm.ClassReader’s constructor throws an IllegalArgumentException is at the class file version check.

So either,

  1. the ASM version used is ancient (rather unlikely),
  2. the version actually is Java 9 (contradicts your setting, but perhaps this operation also parses other classes than those you’ve just compiled), or
  3. the class file is corrupted.

Upvotes: 1

Related Questions