Android Proguard not removing all log messages

Thomas Kaliakos picture Thomas Kaliakos · Sep 12, 2012 · Viewed 15.7k times · Source

I want to create an obfuscated android application. I use ProGuard for that. I would like to automatically remove all the Log.* messages. How can I do that? I found this post but I still get them. (I use a decompiler to check the obfuscation).
The proguard-project.txt is the following:

-injars       libs/In.jar
-outjars      libs/Out.jar
#-libraryjars  <java.home>/lib/rt.jar
-libraryjars C:/Users/thomas/android-sdks/platforms/android-7/android.jar

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keep public class * {
    public protected *;
}

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
}

Any help would be appreciated.
Thanks.

Answer

yorkw picture yorkw · Sep 12, 2012

This only remove all debug Log.d(TAG, "..."); and error Log.e(TAG, "...") calls:

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

To remove all log calls, simply use this:

-assumenosideeffects class android.util.Log { *; }