Please respect other people's labor results, reproduced please specify the Source: "Android Code obfuscation Guide"
This article will share with you the ways to use Eclipse+adt to obfuscate your code with Android studio.
How to use Eclipse+adt for code obfuscation and packaging packaging obfuscation under the new version SDKIf you create an Android project with a new version of the SDK, a proguard-project.txt file is generated at the root of the project, which is the default obfuscation rule file. to obfuscate the packaging steps:1. In the Proguard-project.txt file, add the confusing project rules, you can refer to: "The confusion rules of the Android code confusion" article. 2. Add the #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt in the Project.Properties file: Proguard-project.txt before the # number to go. such as:
at this point, the configuration for obfuscation has been completed. 3. Package the project, then: Right-click on the project "Export" Select Export android Application "Next" Select the Android Project key (no words can create a) "finish." at this point, the project has been confused packaging completed, if not at ease, you can use the "Android Development Anti-compilation and anti-compilation " in the article described in the method of the test after the confusion of the code. Note: It is not confusing to run a program-generated installation package directly.
packaging obfuscation under the old version SDKprojects created under the older version of the SDK do not generate proguard-project.txt files but proguard.cfg files. to obfuscate the packaging steps:
1. In the proguard.cfg file, add the confusing project rules, you can refer to: "Theconfusion rules of the Android code confusion " article.
2. Add Proguard.config=proguard.cfg to the project.properties file . such as:
3. The remaining steps are consistent with the methods packaged under the new version of the SDK.
How to use Android studio for code obfuscation and packaging
Projects created using Android Studio generate a Proguard-rules.pro file in the root of the project, which is a confusing rule file.
To obfuscate the packaging steps:
1. In Proguard-rules.pro file to add confusing project rules, you can refer to: The confusion rules for Android code confusion article.
2. Change minifyenabled false to minifyenabled true in the Build.gradle file under module.
Such as:
Buildtypes { Release { minifyenabled true proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro ' } }
Where: Proguardfiles getdefaultproguardfile (' proguard-android.txt ') means to get the default in the ' Proguard-android.txt ' file under the SDK obfuscation rules.
' Proguard-rules.pro ' means using the obfuscation rules in the ' Proguard-rules.pro ' file under the project root directory.
Hint: The Proguard-rules.pro file name can be arbitrary, as long as it is indicated in the configuration file. For example, to copy a proguard.cfg obfuscation rule file from another project, simply change the above code to Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard.cfg', this sentence means using the Proguard.cfg file in the project's root directory as the obfuscation rule file for this project.
3. Package your project and package it using the Generate signed APK under the Build menu. Note, remember to select release under the Build Type: option, otherwise packaging is not confusing. such as:
》》
Recommended reading: " anti-compilation and anti-compilation of Android development
the Android code obfuscation tips
Android Code obfuscation Guide