Obfuscation code using android proguard

Source: Internet
Author: User

Although there are many related blogs on the Internet, they do not seem to be the latest version .. So the open-source demo on Baidu + Google + github finally successfully configured android proguard. The default configuration of the latest android sdk can meet most of our requirements. We only need to follow the sdk prompts to configure most of the required configurations, then add some basic custom configurations. Step 1: cancel the comments about proguard in project. properties. In this step, proguard can be enabled. Based on the blog on the Internet, 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 so that the default configuration file will also be included. Step 2: Save the class called by AndroidManifest. xml or webview. This is because proguard will remove the code that is not called. -Keepclassmembers class fqcn. 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 Step 3: Third-party class library. # Third-party class library-keep class android. ** {*;}-keep class com. jeremyfeinstein. slidingmenu. lib. ** {*;}-keep class com. actionbarsherlock. ** {*;}-keep class com. lidroid. xutils. ** {*;} in Step 4, this step can replace all the above keep statements to minimize the probability of accidental deletion. That is, keep all classes with public access permissions and their public members. -Step 5 of keepclasseswithmembers class * {public *;}: Delete the Log Code-assumenosideeffects class android, which was introduced in the open-source proguarddemo on github. util. log {public static *** e (...); public static *** w (...); public static *** wtf (...); public static *** d (...); public static *** v (...);} then run it. It is obfuscated and can be run...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.