I am trying to use proguard to strip all my logs: I have entered the following line in my proguard-project.txt:
-assumenosideeffects class android.util.Log { *; }
And my project.properties looks like this:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
Inspite of this the logs continue to show in my application. What exactly am I doing wrong here?
You shouldn't specify the '*' wildcard, because that includes methods like 'Object#wait()'. Better explicitly list the methods:
-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(...);
}
This option is only relevant if optimization is not disabled, like in proguard-android.txt
. You have to specify proguard-android-optimize.txt
instead:
proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
or with the contemporary Android Gradle plugin
buildTypes {
releaseSomeBuildType {
...
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'your-proguard-file.pro'
}
}