Android Jack Compiler not removing logs from proguard rules

632 Views Asked by At

I have tried using:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

in Proguard to remove logs, and it works great if I'm not using the new Jack compiler

defaultConfig {
    ...
     jackOptions {
         enabled true
     }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

When I compile the apk, I have noticed all logs being active in production release. Is there an error, bug or is "-assumenosideeffects" not supported yet?

Can I do something else te remove strings from logs in the final apk ?

1

There are 1 best solutions below

3
On

When using the Jack compiler toolchain, ProGuard will not be used. Instead, Jack will use its own tool to apply the specified rules.

Not all ProGuard rules are supported (see supported directives): -assumenosideeffects is not supported.

Note: DexGuard, the commercial variant of ProGuard supports all directives from ProGuard and can be used in combination with Jack starting from version 7.2, to be released in 1-2 weeks.