Android Development--confusing compilation

Source: Internet
Author: User

As is known to all, the Android apk file is very easy to decompile, so for developers, hard to develop the application is a frustrating thing, Google also recognized this, So since 2.3, a code obfuscation tool has been provided for developers, and the new version of ADT-created projects will have more than two code obfuscation files by default, Proguard.



Proguard.cfg is the legendary confusion script, the specific content is 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 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
-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 *;
}

If your project introduces Google's extra support package (for example, Android-support-v4.jar), you can add a sentence to the script

-dontwarn android.support.**

If your project has a third-party support package, you can add it to the script above by referencing the following format:

-libraryjars Libs/base64coder.jar

Well, the configuration of the above file script even if completed, the rest of the work is to get the script to take effect, the default confusion is not open, you need to add a sentence in the project.properties file proguard.config=proguard.cfg to take effect ;



Finally, by exporting and signing, your apk is confused, and below is:

Android Development--confusing compilation

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.