Android security-code security 1-proguard obfuscation

Source: Internet
Author: User

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:

  1. # this file is automatically generated by android tools. 
  2. # Do not modify the This file--YOUR changes'll be erased!
  3. #
  4. # This file must is checked in Version Control Systems.
  5. #
  6. # to customize  properties used by the ant build system use, 
  7. # "Ant.properties", and override values to adapt the script to your
  8. # project structure.
  9. # Project Target.
  10. target=android-8 
  11. 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

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.