"Go " use Android Proguard to confuse code to prevent decompile, optimize code
Although there are many related blogs on the internet, it seems that they are not the latest version. So Baidu + Google +github on the open source demo, finally successfully configured the Android Proguard.
The latest version of the Android SDK default configuration has been able to meet most of our requirements, we only need to follow the SDK prompts to configure most of the necessary configuration, and then add some basic
The custom configuration is OK.
- The first step is to cancel the comment on the project.properties inside the Proguard. This step can be turned on proguard. According to the online blog, it is best to add the SDK path.
sdk.dir=d:/java/ide/adt-bundle-windows-x86_64-20130219/sdkproguard.config=${sdk.dir}/tools/ Proguard/proguard-android.txt:proguard-project.txt
The default configuration file is also included.
- The second step is to save the class that is called by Androidmanifest.xml or WebView. This is because Proguard removes code that has not been called.
-keepclassmembersclassFqcn.of.javascript.Interface. for. WebView { Public*;}-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
- Third step, third-party class library.
#第三方类库-Keepclass android.** {*;} -Keepclass com.jeremyfeinstein.slidingmenu.lib.** {*;} -Keepclass com.actionbarsherlock.** {*;} -Keepclass com.lidroid.xutils.** {*;}
- The fourth step, in fact, this step can replace all of the above keep statement, the probability of deleting the mistake to a minimum. That is, all classes that have public access and their public members are reserved.
-keepclasseswithmembersclass *{ public *;}
- Fifth step, open source Proguarddemo on GitHub to school, delete the log code
-assumenosideeffectsclass android.util.Log { publicStatic * * * e (...); Public Static * * * W (...); Public Static * * * * wtf (...) ; Public Static * * * * D (...) ; Public Static * * * V (...);}
Configure the confusion and finally package the project:
Then I decompile the exported apk as follows:
Found in the generated jar file, all the class names, variable names into the A,b,c and so on can not correctly understand the name, achieve the desired effect.
[The above content is not pro-test, the content is the source of the network]
Reference Address:
http://blog.csdn.net/binyao02123202/article/details/18940715
http://blog.csdn.net/pomme_qixiaohu/article/details/8551918
Http://www.2cto.com/kf/201207/144771.html
Proguard-project.txt and Project.Properties obfuscation codes