Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing logging with Proguard and optimized Android config file

My Proguard config file uses the following to remove log statements:

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
}

Apparently this only takes effect when optimizations are turned on, so I reference proguard-android-optimize.txt in my project properties file, instead of proguard-android.txt.

Is this a inconsequential change to make? proguard-android-optimize.txt says "Adding optimization introduces certain risks, since for example not all optimizations performed by ProGuard works on all versions of Dalvik" What exactly does this mean, and can I possibly not use proguard-android-optimize.txt and instead add just the optimization statements that are necessary to my own config file so that log removal takes effect?

Thanks. Total Proguard novice.

like image 404
Steveo Avatar asked Jul 17 '13 21:07

Steveo


1 Answers

You can indeed only remove logging if optimization is enabled.

Optimization should be pretty stable in current versions of ProGuard. You can replace <android.sdk>/tools/proguard/lib/proguard.jar with the latest version if you wish. For instance, version 4.9 has improvements to remove traces of logging from the code, compared to version 4.7 in the Android SDK at this time of writing (indicated by the output of "java -jar proguard.jar").

like image 132
Eric Lafortune Avatar answered Nov 15 '22 08:11

Eric Lafortune