Android code obfuscation and project announcement step recorder

Source: Internet
Author: User
Tags xml attribute

Originally put together the Android project was confused with the published file. I suddenly thought, why not write blog, share. There are cases of this article.

Android code obfuscation and project announcement step record

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

Second, change the version number in the manifest file to the current version number, if you need to update the database, you need to change the program database version number 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 the 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

Suppose the project References library project. Then eclipse should actively produce android.library.reference.1 in the project.properties file itself. N=. /libraryprojectname

Eight, Suppose the project includes svntmp ( usually in the bin directory of the project ) . It should be removed in a timely manner , or it will cause packaging to fail.

Nine, the project packaging, installation test ( preferably using an existing build package for the upgrade Test )

Attached: Demo 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 today. For project protection purposes, the project package name has been replaced with com.wly.xxx, and readers can change it based on their own projects!

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

2. The orange content is used to specify the jar files in the program (the library project that can see the references 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 of Web JS local native call processes should not be confused between components.

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Android code obfuscation and project announcement step recorder

Related Article

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.