How does Android prevent the APK program from being decompiled?

Source: Internet
Author: User
As an Android app developer, you have to face an embarrassing situation: applications that have worked hard to develop can be decompiled easily by others. Google also seems to have discovered this problem. From sdk2.3, we can see that the proguard folder under Android-SDK-Windows \ tools \ contains a Java Code The obfuscation tool, through proguard, even if someone decompile your APK package, will only see some very ugly code, so as to protect the code. Let's talk about how to make the proguard. cfg file under sdk2.3 take a look at the content of Android-SDK-Windows \ tools \ Lib \ proguard. cfg:-optimizationpasses resume! Code/simplification/arithmetic ,! Field /*,! Class/merging/*-keep public class * extends android. app. activity-keep public class * extends android. app. application-keep public class * extends android. app. service-keep public class * extends android. content. broadcastreceiver-keep public class * extends android. content. contentprovider-keep public class * extends android. app. backup. backupagenthelper-keep public class * extends android. preference. P Reference-keep public class COM. android. vending. licensing. ilicensingservice-keepclasseswithmembernames class * {native <Methods >;}-keepclasseswithmembernames class * {Public <init> (Android. content. context, android. util. attributeset);}-keepclasseswithmembernames class * {Public <init> (Android. content. context, android. util. attributeset, INT);}-keepclassmembers Enum * {public static ** [] valu ES (); public static ** valueof (Java. lang. string);}-keep class * implements android. OS. parcelable {public static final android. OS. parcelable $ creator *;} from the script, the obfuscation retains basic components inherited from activity, service, application, broadcastreceiver, contentprovider, and COM. android. vending. licensing. ilicensingservice, retains all native variable names and class names, And some of all classes Use constructors with fixed parameter formats, enumerations, and so on. (For more information, see examples and comments in <proguard_path>/examples .) Make proguard. CFG works very easily, that is, the default automatically generated in eclipse. add "proguard. config = proguard. cfg. the properties file should be as follows: # This file is automatically generated by Android tools. # Do not modify this file -- your changes will be erased! # This file must be checked in version control systems. # to customize properties used by the ant build system use, # "build. properties ", and override values to adapt the script to your # project structure. # project target.tar get = android-9proguard.config = proguard. CFG is complete. After the signature is compiled properly, the code can be decompiled. The Code obtained from the decompiled APK after code obfuscation should be similar to the following, which is hard to understand: if you are using an SDK version earlier than 2.3, it doesn't matter, put the above proguard. copy the cfg file to the project and perform the same operation.
Related Article

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.