Android--code obfuscation

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/47376377

Android itself can implement code obfuscation, Android integrated code obfuscation features, these features in the Android SDK tools have a Proguard directory, this directory is to provide the Andoid code obfuscation, We only need to make simple configuration in the Android project.

1. proguard.cfg file

After creating the Android project, there is a proguard.cfg file in the root directory of the Android project, which describes the confusing configuration of Android.

Specific as follows:

-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 * extends Android.app.backup.backupagenthelper-keep public class * extends Android.preference.preference-keep public class Com.android.vending.licensing.ilicensingservice-keepclasseswithmembernames class * {native <methods>;} -keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet);} -keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet, int);} -keepclassmembers class * extends android.app.Activity {public void * (andRoid.view.View);}    -keepclassmembers enum * {public static **[] values (); public static * * VALUEOF (java.lang.String);} -keep class * Implements android.os.Parcelable {public static final Android.os.parcelable$creator *;}

2. project.properties file

This file is an environment configuration file for the entire project, and we only need to specify the configuration of the code mix in this file. Just add one line of configuration to your code

Proguard.config=proguard.cfg
Such as:


This makes the code confusing.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android--code obfuscation

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.