Android implements code obfuscation by adding proguard.cfg files

Source: Internet
Author: User

If there is no proguard.cfg file in the project, manually add

New text, enter the following code

-dontwarn//If a third-party jar package is imported into the project, you need to add the row-optimizationpasses 5- Dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations!code/ Simplification/arithmetic,!field/*,!class/merging/*-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 Androi D.content.broadcastreceiver-keep public class * extends Android.content.contentprovider-keep public class Com.android.vending.licensing.ilicensingservice-keepclasseswithmembernames class * {native<Methods>;} -keepclasseswithmembernames class * { public<Init>(Android.content.Context, android.util.AttributeSet);} -keepclasseswithmembernames class * { public<Init>(Android.content.Context, android.util.AttributeSet, int);} -keepclassmembers enum * {public static **[] values ();p ublic static * * VALUEOF (java.lang.String);} -keep class * Implements android.os.Parcelable {public static final Android.os.parcelable$creator *;}

Rename Text to Proguard.cfg

Copy the file to the project, at the same level as the Androidmanifest.xml file

Open the Project.Properties file, and add the following

Proguard.config=proguard.cfg

Save, right-click the project name->android-tools->export Unsigned application Package

Build Project APK, confuse complete

If the process is reported java.io.IOException:Please Correct the above warnings this error, may be forgotten in proguard.cfg add-dontwarn Add and try again.

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.