3

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'
}
Mike Laren
  • 8,028
  • 17
  • 51
  • 70

1 Answers1

4

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...

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
  • so you can publish this app on play store without proguard? – Arnav M. Jun 09 '16 at 06:00
  • 1
    Turns out that Jack takes care of running ProGuard internally, so the only thing we have to do is disable the `minifyEnabled` flag so that ProGuard doesn't run twice. – Mike Laren Jun 09 '16 at 20:46
  • ok.. do you know where mappings.txt goes using JACK.. http://stackoverflow.com/questions/38196100 – Arnav M. Jul 05 '16 at 09:00