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]