references :
http://developer.android.com/tools/help/proguard.html
http://proguard.sourceforge.net/
http://sourceforge.net/p/proguard/discussion/182456/thread/e4d73acf/
howto :
At project location always there are two files project.properties and proguard-project.txt.
first enable the proguard (obfuscation take place on release only, no for debug) via project.properties (unrem proguard.config)
${sdk.dir}/tools/proguard/proguard-android-optimize.txt - proguard is always at androidSDK folder
proguard-project.txt - by default look to your android project/proguard-project.txt
setup the proguard-project.txt (only when having problems)
otherwise ${sdk.dir}/tools/proguard/proguard-android-optimize.txt contains the default obfuscation parameters.
most of the time, when using 3rd party jar's because contain reference to 4th party assemblies we got errors (obfuscation failed) such as cant find a specific classes that we dont even know it... !
warning dont use -injars -outjars -libraryjars swtiches, most of the users suggest to use them, dont use them, there is no need!
we use the -dontwarn switch, example :
we use -keepnames switch, example :
another usual error is that 'proguard removes annotations' we use -keepattributes to disable the removal :
combine with -keep (3rd party jar, performs introspection on parsed classes to find getters and setters) :
or for a type :
the events declared to activity xml's can continue work with -keepclassmembers (already at proguard-android-optimize.txt) :
when having troubles with enums
for android.os.Bundle's obfuscation problems (thanks garymb) :
remove all log.* lines from code :
VA1
VA2
http://developer.android.com/tools/help/proguard.html
http://proguard.sourceforge.net/
http://sourceforge.net/p/proguard/discussion/182456/thread/e4d73acf/
howto :
At project location always there are two files project.properties and proguard-project.txt.
first enable the proguard (obfuscation take place on release only, no for debug) via project.properties (unrem proguard.config)
JavaScript:
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
${sdk.dir}/tools/proguard/proguard-android-optimize.txt - proguard is always at androidSDK folder
proguard-project.txt - by default look to your android project/proguard-project.txt
setup the proguard-project.txt (only when having problems)
otherwise ${sdk.dir}/tools/proguard/proguard-android-optimize.txt contains the default obfuscation parameters.
most of the time, when using 3rd party jar's because contain reference to 4th party assemblies we got errors (obfuscation failed) such as cant find a specific classes that we dont even know it... !
warning dont use -injars -outjars -libraryjars swtiches, most of the users suggest to use them, dont use them, there is no need!
we use the -dontwarn switch, example :
JavaScript:
-dontwarn org.apache.**
-dontwarn org.shaded.apache.**
-dontwarn org.brickred.**
-dontwarn com.squareup.okhttp.**
we use -keepnames switch, example :
JavaScript:
-keepnames class com.shaded.fasterxml.jackson.** { *; }
another usual error is that 'proguard removes annotations' we use -keepattributes to disable the removal :
JavaScript:
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
//or if you still have problems use :
-keepattributes **
combine with -keep (3rd party jar, performs introspection on parsed classes to find getters and setters) :
JavaScript:
-keep public class com.ourPRJtest.** {
public void set*(***);
public *** get*();
}
or for a type :
JavaScript:
-keep class org.shaded.apache.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v4.** { *; }
the events declared to activity xml's can continue work with -keepclassmembers (already at proguard-android-optimize.txt) :
JavaScript:
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
when having troubles with enums
JavaScript:
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
for android.os.Bundle's obfuscation problems (thanks garymb) :
JavaScript:
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
remove all log.* lines from code :
JavaScript:
-assumenosideeffects class android.util.Log { public * ; }
VA1
JavaScript:
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
VA2
JavaScript:
-dontobfuscate
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers