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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.