Android code obfuscation prevents Decompilation

Source: Internet
Author: User

Android code obfuscation prevents Decompilation

To prevent code decompilation, you need to add obfuscation. Obfuscation can also be performed by a third party or by using proguard in android.

Obfuscation steps:

1. The configuration obfuscation file can be named at will. Use proguard-android here in the format of txt.

 

-Optimizationpasses 5 # specify the compression level of the code-dontusemixedcaseclassnames # whether to use case-sensitive hybrid-dontskipnonpubliclibraryclasses # Whether to confuse third-party jar-dontpreverify # Whether to perform pre-check-verbose -optimizations! Code/simplification/arithmetic ,! Field /*,! Class/merging/* # algorithm used for obfuscation-keep public class * extends android. app. activity # keep classes that are not Obfuscated-keep public class * extends android. app. application # keep classes that are not Obfuscated-keep public class * extends android. app. service # Do not confuse classes-keep public class * extends android. content. broadcastReceiver # keep classes that are not Obfuscated-keep public class * extends android. content. contentProvider # Do not confuse classes-keep public class * extends android. app. backup. backupAgentHelper # keep classes that are not Obfuscated-keep public class * extends android. preference. preference # keep classes that are not Obfuscated-keep public class com. android. vending. licensing. ILicensingService # Keep which classes are not Obfuscated-libraryjars libs/gson-2.0.jar # Keep third-party jar not Obfuscated-keepclasseswithmembernames class * {# Keep native METHOD not obfuscated native
 
  
;}-Keepclasseswithmembers class * {# Keep the custom control class public
  
   
(Android. content. Context, android. util. AttributeSet);}-keepclasseswithmembers class * {public
   
    
(Android. content. context, android. util. attributeSet, int); # Do not confuse custom control classes}-keepclassmembers class * extends android. app. activity {# Keep the custom control class from being confused with public void * (android. view. view);}-keepclassmembers enum * {# Keep The enum class from being confused public static ** [] values (); public static ** valueOf (java. lang. string);}-keep class * implements android. OS. parcelable {# Keep Parcelable not to be confused public static final android. OS. parcelable $ Creator *;}-keepclassmembers class **. r$ * {# Keep the R file not confused public static
    
     
;}-Keep class com. alipay. android. app. IAliPay {*;} # keep an interface or class unobfuscated-keep class com. android. app. view ** {*;} # keep all classes under a certain package intact-keep class com. android. app. commonCallback {# keep the public and protected type members and methods of a class or interface not confused public protected
     
      
; Public protected
      
        ;}-Keep class com. android. app. platform $ * {# keep internal classes not confused *;} #-keep class com. android. app. ** implements com. android. app. platform $ ICallback {*;} # Keep internal interfaces unobfuscated-dontwarn android. support. **
      
     
    
   
  
 
2. Introduction

 

Add proguard.configpolicproguard-android.txt to the project project.propertiesfile, which is the obfuscation file written above.

3. The default runtime environment for android is debug mode, which does not confuse Execution Code. Therefore, you must sign the project. If an error occurs during packaging, it may be caused by a problem where the obfuscation file is written.

 


 

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.