I have enabled proguard by un-commenting the line in project.properties.
I decompiled my APK to check if it worked. I can see that all my methods, variable names and class names have been changed to a,b,c.. etc which is good. However my Activity classes have not been renamed. Also the Log.d statements were not removed as expected.
How can I make it harder for someone to read the decompiled code and also remove the log statements?
Various methods related to the Android application lifecycle cannot be renamed, because:
onCreate()
to a()
will therefore cause a compilation problem due to the @Override
annotation.onCreate()
and onResume()
). If your onCreate()
is renamed to a()
, only the superclass implementation will be executed -- not yours.As for why your Activities' class names can't be renamed:
A
, may now be obfuscated to B
.Getting your Log statements removed through Proguard is fairly simple using the assumenosideeffects option. See this related question for details:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
Paul Lammertsma has provided an accurate answer to the first part of your question. Elaborating on the second part:
You can only remove logging if optimization is not disabled, which requires specifying a different global configuration file in project.properties
:
proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
These settings in proguard-project.txt
then remove all logging:
-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(...);
}
There are various equivalent forms with more or fewer wildcards.
Similar questions and answers:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With