In order to prevent the results of their own work stolen by others, confusing code can effectively prevent the anti-compilation, the following to summarize the following steps to confuse the code:
2, edit the Proguard-project.txt under the project, add the rules that do not need to be confused (model, generics, reflection, third-party jar package), the contents of the Proguard-project.txt file are as follows:
# To enable Proguard in your project, edit project.properties# to define the Proguard.config property as described in That file.## ADD project specific Proguard rules here.# bydefault, the flags in Thisfile is appended to the flags specified# in ${sdk.dir}/tools/proguard/proguard-android.txt# You can edit the include path and order by changing the proguard# include property in Project.Properties. # for more details, see# http://developer.android.com/guide/developing/tools/proguard.html# ADD any project specific keep options here:# If your project uses WebView with JS, uncomment the following# and spec Ify the fully qualifiedclassName to the JavaScriptInterface# class:#-keepclassmembersclassFqcn.of.javascript.Interface. for. WebView {# Public*#}############################################## The main program cannot confuse the code ################################################ ####-dontwarn xxx.model.**######-keepclassxxx.model.** {*; } ################################################ non-optimized generics and reflection ###############################################-keepattributes Signature-keepclass*extendsjava.lang.annotation.Annotation {*; } ############################################## does not confuse third-party libraries or jar packages ############################################-dontwarn Net.sourceforge.jtds.**-keepclassnet.sourceforge.jtds.** {*; }-dontwarn Com.iflytek.speech.**-keepclasscom.iflytek.speech.** {*; }-dontwarn Com.lidroid.xutils.**-keepclasscom.lidroid.xutils.** {*; } #####################################
Tip: The third-party jar package name can be used winrar to open the jar file and get the package path. For example: Jtds-1.2.jar, with winrar view, you can find the package name: Net.sourceforge.jtds, so you just add the following 2 lines of code, you can not confuse the jar file related packages and classes:
class net.sourceforge.jtds.** {*;}
Reference article:
1, http://blog.csdn.net/lovexjyong/article/details/24652085
2, http://www.cnblogs.com/qianxudetianxia/p/4948499.html
Android Development Code obfuscation experience (Eclipse)