Android security-code security 1-proguard obfuscation
Proguard Introduction
Proguard is a very well-known open source project on SourceForge. Website website is: http://proguard.sourceforge.net/.
Java bytecode is generally very easy to decompile. In order to protect the Java source code very well, we often confuse the compiled class file. The main function of Proguard is to confuse. Of course, it can also reduce the size of bytecode, optimization, and so on, but those for us is a secondary function.
Android Eclipse Development Environment and Proguard
Before Android 2.3, it was very inconvenient to confuse Android code by manually adding Proguard for code obfuscation. After 2.3, Google has added this tool to the SDK's toolset. Specific path: Sdk\tools\proguard. When you create a new Android project, a proguard configuration file proguard.cfg appears under the root path of the project directory. In other words, we can use the simple configuration to confuse Android engineering directly with Proguard in our Elipse project.
The exact steps to confuse are very simple. First, we need to add a sentence in the project description file Default.properties to enable Proguard. As shown below:
- # this file is automatically generated by android tools.
- # Do not modify the This file--YOUR changes'll be erased!
- #
- # This file must is checked in Version Control Systems.
- #
- # to customize properties used by the ant build system use,
- # "Ant.properties", and override values to adapt the script to your
- # project structure.
- # Project Target.
- target=android-8
- Proguardproguard.config=proguard.cfg
In this way, the Proguard can be used. When we export the application package normally through Android tools, Proguard is automatically enabled and the optimization confuses your code.
After the export is successful, you can reverse-compile to see the effect of confusion. Some class names, method names, variable names, and so on, all become meaningless letters or numbers. Prove the confusion is successful!
Android security-code security 1-proguard obfuscation