Search code examples
androidproguardlogcat

Android Proguard Options - cannot remove log


I tried to follow this post How to config my proguard-project.txt file to remove just Logs but i failed to remove log. I tried for an hours...please help..

I updated android ADT to v22.

For all of below files,

\sdk\tools\proguard\proguard-android-optimize.txt
\sdk\tools\proguard\proguard-android.txt
proguard-android.txt of (my android project)

I added:

-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(...);
}

I then export my app and install to a device. I start my app, and i can still see the log.d line in logcat. What steps do I miss? thank a lot for help!


Solution

  • As explained in the question that you mention, you should

    1. Update project.properties in your project, so the configuration path refers to ${sdk.dir}/tools/proguard/proguard-android-optimize.txt instead of ${sdk.dir}/tools/proguard/proguard-android.txt. This file enables ProGuard's optimization step, which is the step that can remove logging.
    2. Add the -assumenosideeffects lines to proguard-project.txt in your project.

    You probably shouldn't change any files in the Android SDK, since they will get overwritten the next time you update the SDK.