Obfuscation packaging specification for Android applications

Source: Internet
Author: User

Obfuscation Packaging specification for Android applications

1. Add the following proguard.config=proguard.cfg to the project file project.properties as follows:

Target=android-8

Proguard.config=proguard.cfg

This configuration is used by Eclipse to generate the proguard.cfg file in the project catalog , but this can only confuse projects that do not contain third-party packages.

third party Package cause the packaging to be unsuccessful, Or packaging success can not run the situation

2. Engineering confusion with third-party libraries, first to look at the official documentation of the reference library, usually gives a confusing scenario, because sometimes a third-party library might not have only one jar package, and the third-party library itself may also use other jars Bag, it's a waste of time to find a separate mix.

3. Common third-party library obfuscation process:

1. First add -dontwarn// without output warning , increase the success rate of confusion

2. remove the warning from the package name of the corresponding third-party library by using the same method

-dontwarn com.slidingmenu.lib.app.**

-dontwarn com.actionbarsherlock.app.**

-dontwarn android.support.v4.**

-dontwarn com.slidingmenu.lib.**

-dontwarn cn.sharesdk.**

3. specify the path of the Lib package in the project,,,-libraryjars followed by other class packages to compile in.jar , If there are multiple, With a multi-row

-libraryjars Libs/gson-2.2.2.jar

4. after introduction, specify the entry class to which the project is used,-keep followed by the entry class for the project

-keep class universal-image-loader-1.8.4-with-sources.** {*;}

-keep interface universal-image-loader-1.8.4-with-sources.** {*;}

-keep class locksdk_3.3.** {*;}

-keep interface locksdk_3.3.** {*;}

-keep class mobileprobe.jar.** {*;}

-keep interface mobileprobe.jar.** {*;}

-keep class Android.net.http.SslError

-keep class android.webkit.**{*;}

-keep class cn.sharesdk.**{*;}

-keep class com.sina.**{*;}

Keep is telling Proguard not to confuse the class inside this bag.

5. Some special packages need attention

If you add a android.support bag, then add

-libraryjars Libs/android-support-v4.jar

-dontwarn android.support.v4.**

-keep class android.support.v4.** {;}

If you add a gson bag, then add

-libraryjars Libs/gson-2.2.2.jar

-keep class Sun.misc.Unsafe {*;}

-keep class com.google.gson.stream.* {;}

-keep class Com.google.gson.examples.android.model.* {;}

-keep class Com.google.gson.* {*;}

If the project contains entities referencing interfaces , then add

-keep public class * Implements java.io.serializable{

public protected Private *;

}

IfEntity with set value injection in ProjectWords,May be in the packaging run without error, For example, NULL pointer exception, or reflection when the error is not cannot get or set

-keep public class MyPackage. Mybean {public void Setmyproperty (int.); public int getmyproperty ();}

4. Finally, let's take a look at the process of confusion

-libraryjars Libs/android-support-v4.jar

-dontwarn android.support.v4.**

-keep class android.support.v4.** {;}

Explain:

-libraryjarsindicateLibThe path of the package in the project,and-dontwarn android.support.v4.**and the-keep class android.support.v4.** {;},These two parameters are used To keep classes in third-party libraries-dontwarnand the-keepto use together means to keep android.support.v4.**  { ; }, The presence of an acceptable warning affects the operation of the program.

Note: confusing the basic process, that is, different third-party libraries are similar, you can use this method to deal with!!!

Obfuscation packaging specification for Android applications

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.