1

I use

-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(...);
    public static java.lang.String getStackTraceString(java.lang.Throwable);
}

However when I decompile, I see the one and only custom string I used in a Log.d line in decompiled jar file. How can that be possible? Doesn't Proguard remove Log.d lines completely?

frankish
  • 6,738
  • 9
  • 49
  • 100

2 Answers2

0

This is relevant if proguard optimization is enabled i.e. your proguard.config is this

proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103
  • my proguard.config line is exactly like that. What's the reason behind it? How can I still use optimization but also remove strings in Log.d lines? – frankish Jan 28 '15 at 14:55
0

Just for clarification, it's my understanding optimisation 'has' to been enabled for the log calls to be stripped.

You could try using a Log wrapper class (like this one) to wrap android.util.Log. I used this approach due to a note from Eric (a.k.a Mr Proguard) in this answer about how Proguard inspects the code. So this ends up with a simpler call to Log.d(tag, string) rather than Log.d(tag, string + value+ String)

Or use DexGuard IIRC is has some explicit function for log removal. -- [update: sorry my bad it's not a explicit function DexGuard uses the same config as you noted. I guess I was thinking the fact the decompiled code is more mangled with DexGuard.]

Community
  • 1
  • 1
scottyab
  • 23,621
  • 16
  • 94
  • 105
  • So, according to the wrapper class you have shared, when I use `QLog.d('myclass','my string ->'+myvalue);` and configure the Proguard to remove those lines, won't 'my string ->' be visible? Isn't it the same? What's the logic? (I have DexGuard but I am not aware of that special function :| ) – frankish Jan 28 '15 at 19:21
  • Hmm, I'll need to double check by reversing one of my apps if 'my string ->' is still visible. I misread you're main objective, I thought you were trying to stop the ProGuarded app from logging. – scottyab Jan 29 '15 at 09:24
  • I check the LogCat while my app is running and nothing is outputted (correctly). But ProGuard (DexGuard) does not touch that string some how.. (I see it when I decompile the dex file) – frankish Jan 29 '15 at 13:16