Android obfuscation [Learning notes]

Source: Internet
Author: User

Android Obfuscation

Gradle's introduction: http://www.flysnow.org/2015/03/30/manage-your-android-project-with-gradle.html
Introduction to Multi-channel packaging: http://blog.csdn.net/tu_bingbing/article/details/42362619
Http://coolshell.info/blog/2015/03/android-studio-prefrence.html

Current Android studio version 1.4, target APK 5.0 (21). Main reference this article: http://www.cnblogs.com/Supperlitt/p/4214949.html

1. Modify Build.gradle
Signingconfigs {
Release {
StoreFile file (' Release.keystore ')
Storepassword "123456"
Keyalias "Androiddebugkey"
Keypassword "123456"
}
Debug {
StoreFile file (' Release.keystore ')
Storepassword "123456"
Keyalias "Androiddebugkey"
Keypassword "123456"
}
}

Buildtypes {
Release {
minifyenabled true//set code to confuse
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
Signingconfig signingconfigs.release//Signature configuration
}
}

In previous versions.
A> we're using runproguard, but now we're using minifyenabled. Setting to True is confusing.
B> proguradfiles Specifies a file that is configured to confuse the project, you can see that Progurad-rules.pro is used. This is what we will use for subsequent configurations to exclude confusion and run the environment.

2. Create a KeyStore file, using the command line or Android Studio menu "Build--Generate signed APK--Create new"
CD users\user\.android
Keytool-genkey-v-keystore Release.keystore-alias Androiddebugkey-keyalg rsa-validity 10000
Copy the generated Release.keystore file to the same directory as the Build.gradle file.

3. Modify the Progurad-rules.pro to add the following:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

Note: If you use a third-party jar, you do not need to be confused, or have been confused to avoid problems. You can add the following content to the Progurad-rules.pro file.
-dontwarn com.android.support.**
-keep class com.android.support.** {
*;
}
I use Android to bring it, I don't think I need it.

4. The menu "Build-, select Build vaiants" selects release and generates this every time, or "Build->generate signed APK".

Ps:eclipse's confusion, see: http://blog.csdn.net/vipzjyno1/article/details/21042823
The way to make proguard.cfg work is simply to add a "proguard.config=proguard.cfg" to the Eclipse Auto-generated default.properties file.

Android obfuscation [Learning 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.