Android Code obfuscation notes

Source: Internet
Author: User

The obfuscation apk is hard to understand, such as the package name Class name in the anti-compilation code.

Use code obfuscation, enable the obfuscation, edit the relevant files, and then package the signature on it;

------------

In the 2.3 version, the project has this file proguard.cfg (no can be added manually)

Add a sentence: proguard.config=proguard.cfg

Contents of the Proguard.cfg file:

-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 Com.android.vending.licensing.ilicensingservice-keepclasseswithmembernames class * {native <methods>;} -keepclasseswithmembernames class * {public <init> (Android.content.Context, android.util.AttributeSet);} -keepclasseswithmembernames class * {public <init> (Android.content.Context, android.util.AttributeSet, int);}    -keepclassmembers enum * {public static **[] values (); public static * * VALUEOF (java.lang.String);} -keep class * Implements android.os.Parcelable {public static final Android.os.ParcElable$creator *;} 

-------------------------

In the version after 4.0, the files in the project are Project.Properties and Proguard-project.txt.

Open Project.Properties and uncomment the following line of code:

Proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

The default settings are not optimized, and you can use the following settings to add code optimization features:
#proguard. Config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt

-------------------------------------------------------

Some editing rules for proguard-project.txt files:

-libraryjars Libs/android-support-v4.jar

-libraryjars Libs loading third-party jar packages

-ignorewarnings Removing warnings from your code


-keep class com.xxx.xxx.**

-keep preserving non-confusing classes

Public methods of this class are reserved and not confused.
-keep class com.xx.xx.test{
public *;
}

Protecting the specified class files and members of a class

-keep class * Implements Android.os.Parcelable {

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


----------------------------------------------------

To package a signature with the Eclipse tool:

In Eclipse, select Project, right-click Menu--Android Tools

---> Export signed application Package ... With RSA digital signature

---> Export Unsigned application Package ... With no digital signature

Choose a way to follow the wizard, and the resulting apk is a confusing process.

----------------------------------------

Android Code obfuscation notes

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.