Search code examples
androidproguardandroid-proguard

Remove logs using proguard doesn't work


I've a need to remove all logging from my release App type. I've tried configure proguard to do it for me. My configuration mostly match the one provided in here: proguard doesn't remove logs . I've changed proguard-android.txt to proguard-android-optimize.txt but with no luck. After going through Proguard manual and checking output of :

-whyareyoukeeping 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(...);
   public static int wtf(...);
} 

learned that this couldn't be removed because of:

Explaining why classes and class members are being kept...
Printing usage to [...]...
android.util.Log
  is a library class.
android.util.Log: boolean isLoggable(java.lang.String,int)
  is a library method.
android.util.Log: int v(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int v(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int i(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int i(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int w(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int w(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int w(java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int d(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int d(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int e(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int e(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.String)
  is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.Throwable)
  is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.String,java.lang.Throwable)
  is a library method.

What could be reason for that? Maybe some other Proguard option? Is there any other option to enforce logs removal?


Solution

  • With help of Guardsquare support I've been able to find out problem. One of libraries has -dontoptimize in its ProGuard config file. Helpful to narrow down this issue is option -printconfiguration [filename]

    Doc. for ref - https://www.guardsquare.com/en/products/proguard/manual/usage#generaloptions