Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Proguard not removing all log messages

Tags:

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.

like image 274
Thomas Kaliakos Avatar asked Sep 12 '12 14:09

Thomas Kaliakos


2 Answers

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 { *; } 
like image 90
yorkw Avatar answered Oct 08 '22 16:10

yorkw


The default android Proguard configuration disables optimisation. To enable it, in your project's project.properties file use proguard-android-optimize.txt instead of proguard-android.txt

like image 43
Gallal Avatar answered Oct 08 '22 17:10

Gallal