Dexguard security during debugging

1.2k views Asked by At

i am using Dexguard in my android application to protect from reverse engineering.Now in my application which is very big ,i have used several places System.out.println in many classes in which i am printing my server URL to debugg for my ease.Now when i am releasing this application ,and this apk i am giving to other developers ,they can see all the System.out.println things in their logcat. how should i avoid that. This has serious issue.

2

There are 2 answers

3
vKashyap On BEST ANSWER

First of all you shouldn't be using System.out.println directly everywhere. Use your own wrapper class for logging.

In dexguard/proguard you can use assumenosideeffects for removing codes that are unnecessary for release.

So for System.out.print you can add following in your dexguard rules.

 -assumenosideeffects class java.io.PrintStream {
     public void println(%);
     public void println(**);
 }

But this is risky as this class might be used for purposes other than logging.

Fastest way for you would be to use android.util.Log in place of System.out.print and then add following

-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(...);
}

See proguard docs

2
scottyab On

good answer by @vKashyap, you might also want to add this as well...

-assumenosideeffects class java.lang.Exception {
    public void printStackTrace();
}