Jack doesn't seem to obfuscate the code by itself

430 Views Asked by At

I am using Android Studio version v2.1.2 and Proguard doesn't work when I try to sign the release build, the build fails dramatically.

According to this link from developer docs Jack does obfuscation automatically.

Handles shrinking, obfuscation, repackaging and multidex Using a separate package such as ProGuard is no longer necessary.

I had to disable minifyEnabled flag and remove the line where we load proguard file; to get it working, after doing this; I inspected the apk file generated by doing the above and I cannot tell whether Jack really obfuscated and reduced redundant code as the release apk size is same as the debug apk size.

I need to understand how to make obfuscation work with the newer compiler as the documentation doesn't really help.

I am looking forward to understand the following questions.

Does Jack work without Proguard file?

Is there a way to specify Proguard file?

1

There are 1 best solutions below

2
On

The Jack compiler has its own Shrinker and Obfuscator that re-uses existing Proguard rules (see supported directives).

The configuration should be the same as before, so you need to add the following to your buildType configuration:

minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'your-proguard-file.txt'