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.
Asked
Active
Viewed 1,160 times
2 Answers
2
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

vKashyap
- 580
- 6
- 17
-
i have written it so many places in my application .Is there any way to encrypt them or disable them while releasing apk ?? – abh22ishek Nov 19 '14 at 11:46
-
1Isn't this what @vKashyap has suggested? adding these snippets to your proguard/dexguard config file and it will remove them from your compiled release code. have you tried it? – scottyab Nov 19 '14 at 12:17
-
could you also tell me how to encrypt resourece folders in dexguard.it is not working . i can get easily my layout files when i decompile my apk – abh22ishek Nov 24 '14 at 07:03
2
good answer by @vKashyap, you might also want to add this as well...
-assumenosideeffects class java.lang.Exception {
public void printStackTrace();
}

scottyab
- 23,621
- 16
- 94
- 105
-
could you also tell me how to encrypt resourece folders in dexguard.it is not working . i can get easily my layout files when i decompile my apk? – abh22ishek Nov 24 '14 at 07:03
-
This would be more appropriate to raise another question and/ or contacting dexguard support. However I guess do you really care about layout files? – scottyab Nov 24 '14 at 07:09