Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot test obfuscated variants when compiling with jack" error when building Android app with Jack toolchain

I'm trying to enable the Jack toolchain in my Android project by following the steps in this article https://developer.android.com/preview/j8-jack.html but as soon as I add

android {
    defaultConfig {
        jackOptions {
            enabled true
        }
    }
}

and run gradle clean, I get this error right away:

Cannot test obfuscated variants when compiling with jack

I tried it with a very simple Android project and I still get the same error. This is a sample gradle.build file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 7
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
}
like image 944
Mike Laren Avatar asked Nov 28 '25 13:11

Mike Laren


1 Answers

D'oh! The fix was really simple. Apparently Jack is not compatible with ProGuard and the line:

release {
    minifyEnabled true
}

enables ProGuard, since it's now called "minify". Switching it to false fixes the issue... I just didn't see the line because it was in a different section...

like image 172
Mike Laren Avatar answered Nov 30 '25 03:11

Mike Laren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!