Preface, the current version of Android studio use newer, lower version if there are differences, or problems, welcome to shoot Bricks!
1. Modify the configuration file
Locate the configuration file,Build.gradle, and modify the following.
1 Signingconfigs {2 Release {3 //The meanings of the following values will be explained in follow-up4StoreFile file (' Release.keystore ')5Storepassword "123456"6Keyalias "Androiddebugkey"7Keypassword "123456"8 }9 Debug {TenStoreFile file (' Release.keystore ') OneStorepassword "123456" AKeyalias "Androiddebugkey" -Keypassword "123456" - } the } - - Buildtypes { - Release { +Minifyenabledtrue //set code to confuse -Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro ' +Signingconfig Signingconfigs.release//Signature Configuration A } at}
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
Entering this file, we can see the *.keysotre file we already have.
I've got a debug.keystore file here, but I don't need it, and I don't remember the password.
So we regenerate one, we can delete the original content, and then regenerate a file.
Of course, we have to go into the. Android folder to operate. Run cmd = input: cd. android = and then enter our command
Keytool-genkey-v-keystore release.keystore -alias Androiddebugkey-keyalg rsa-validity 10000
Complete the subsequent build of such a release.keystore file we generated. The generated files, we need to copy to and above the configuration (build.gradle), the same directory can be.
OK, the next time you run the program is encrypted. But we also want to configure the following environment.
3. Generate re-generated code, can see the file is encrypted after decompile
Progurad-rules.pro
1 -optimizationpasses 52 -dontusemixedcaseclassnames3 - Dontskipnonpubliclibraryclasses4 -dontpreverify5 -verbose
Add the following content. Such a complete and confusing file we can use.
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.
class net.youmi.android.** {*;}
Here are some examples of rice ...
4. Reference page:
http://blog.csdn.net/zhaoxiao2008/article/details/7443020 Debug.keystore file does not exist a workaround
http://blog.csdn.net/hudashi/article/details/9016805 Android Obfuscation Pack
Http://www.bkjia.com/Androidjc/924623.html quickly mastering how Gradle is used in Android Studio
Http://www.cnblogs.com/youxilua/archive/2013/05/20/3087935.html Build your Android app with Gradle
Welcome to shoot Bricks ha!
Android Studio ... Confusing packaging full disclosure