Android code obfuscation and project release method records

Source: Internet
Author: User
Tags xml attribute

Android code obfuscation and project release steps record

Originally compiled a copy of the Android project to confuse and publish the document, suddenly think of why not write a blog, share it, if it has this article.

Android code obfuscation and project release steps record

First, clean up the debugging information in the code, such as log, System.out

Second, modify the version in the manifest file to the current version, if you need to update the database, you need to modify the program database version in the configuration class or configuration file.

Third, set the project's debugable to False in the manifest file

Iv. creating a signing certificate KeyStore file

V. Add a statement proguard.config=proguard-project.txt to the Project.properites file in the project to specify the obfuscation rule file

Vi. Configuration of Proguard-project.txt files

Vii. if the Project References library project, eclipse should automatically produce android.library.reference.1 in the Project.Properties file. N=. /libraryprojectname

Eight, If the project contains svntmp ( typically located under the project's bin folder ) , should be removed in time when packaging , failure to do so will cause packaging to fail.

Ix. Project Packaging, installation testing ( preferably using an existing build package for upgrade testing )

Attached: sample proguard-project.txt file and corresponding instructions:

# This was a configuration file for Proguard.

# http://proguard.sourceforge.net/index.html#manual/usage.html

# optimizations:if you don ' t want to optimize, use the

# proguard-android.txt configuration file instead of this one, which

# Turns off the optimization flags. Adding Optimization introduces

# Certain risks, since for example no all optimizations performed by

# Proguard works on all versions of Dalvik. The following flags turn

# off various optimizations known to has issues, but the list could not

# is complete or up to date. (the "Arithmetic" optimization can be

# used if you is only targeting Android 2.0 or later.) Make sure

# Test thoroughly if you go the this route.

-optimizations!code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*

-optimizationpasses 5

-allowaccessmodification

-dontpreverify

#-dontoptimize

# The remainder of this file are identical to the non-optimized version

# of the Proguard configuration file (except that the other file have

# flags to turn off optimization).

-dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-keepattributes Signature

-verbose

-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

-keepattributes *annotation*

-keep public class Com.google.vending.licensing.ILicensingService

-keep public class Com.android.vending.licensing.ILicensingService

# for native methods, see http://proguard.sourceforge.net/manual/examples.html#native

-keepclasseswithmembernames class * {

Native <methods>;

}

# Keep setters in animations can still work.

# See Http://proguard.sourceforge.net/manual/examples.html#beans

#-keepclassmembers public class * extends Android.view.View {

# void set* (* *);

# * * * * get* ();

#}

# We want to keep methods in Activity that could is used in the XML attribute OnClick

-keepclassmembers class * extends Android.app.Activity {

public void * (Android.view.View);

}

# for enumeration classes, see Http://proguard.sourceforge.net/manual/examples.html#enumerations

-keepclassmembers enum * {

public static **[] values ();

public static * * VALUEOF (java.lang.String);

}

-keep class * Implements Android.os.Parcelable {

public static final Android.os.parcelable$creator *;

}

-keepclassmembers class * *. r$* {

*;

}

# The Support library contains references to newer platform versions.

# Don ' t warn about those in case this app is linking against an older

# Platform version. We know about them, and they is safe.

-keep class * extends android.view.view{*;}

-keep class * extends android.app.dialog{*;}

-keep class * Implements java.io.serializable{*;}

#-ignorewarnings

-libraryjars Libs/locsdk_4.1.jar

-libraryjars Libs/pinyin4j-2.5.0.jar

-libraryjars Libs/libammsdk.jar

-libraryjars Libs/webtrendsandroidclientlib.jar

#-libraryjars Libs/afinallib.jar

#-libraryjars Libs/stickylistheaders_lib.jar

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

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

-keep class org.kobjects.** {*;}

-keep class org.kxml2.** {*;}

-keep class org.xmlpull.** {*;}

-keep class net.tsz.** {*;}

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

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

-keep class net.sourceforget.** {*;}

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

-dontwarn demo.**

-keep class Demo {*;}

-keep class com.wly.xxx.bean.** {*;}

-keep class com.wly.xxx.tool.dbmodelutils{*;}

-keep class com.wly.xxx.tool.jsonutils{*;}

-keep class Com.wly.xxx.activity.InsuranceQuotesActivity

-keep public class Com.wly.xxx.activity.insurancequotesactivity$myjavascriptinterface

-keep public class * Implements Com.wly.xxx.activity.insurancequotesactivity$myjavascriptinterface

-keepclassmembers class Com.wly.xxx.activity.insurancequotesactivity$myjavascriptinterface {

public *;

Private *;

}

File Description:

0. The above documents are copied from the project I have developed now, for the purpose of project protection, the project package name has been replaced com.wly.xxx, readers can be modified according to their own projects!

1. The blue content has the general nature, may copy the paste;

2. The orange content is used to specify the jar files in the program (you can see that the referenced library project does not need to be included because they are already specified in the Project.Properties file).

3. The red content is used to represent the contents of the jar package that is reserved (not confused) for reference.

4. Green Grass content is used to indicate that the entity class under the Bean file reserved locally is not confused.

5. Purple content is used to indicate that classes that retain local reflection are not confused.

6. Green content for special handling the call process between Web JS and native native components is not confused

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.