Questions about how Android Studio uses code obfuscation!

Source: Internet
Author: User
Tags samsung app

    1. Why do you want to confuse code?
    2. Refer to: http://www.cnblogs.com/wangcan/p/3477840.html

1,android Studio 1.3 versions before!

Used to think IntelliJ idea and Android studio in the Proguard-project.txt inside set up, in the compile time directly to the code to confuse, after their own anti-compilation only found, what is confused, there is a operation did not do,

(You'll need to tick the run Proguard on generate signed APK (signature).) ) Focus!! , otherwise copy the code to press generate signed APK button when no effect!

Reference Source: http://blog.sina.com.cn/s/blog_ab9fb58a0102v0sx.html

The 1,android Studio 1.3 version does not have generate signed Apk-run proguard this option!

To put the Build.grandleminifyEnabled  改成Ture 就可以了!

minifyenabled < Span class= "KWD" >true 



Below is the code I used:
#指定代码的压缩级别-optimizationpasses AA Baoming do not mix case-dontusemixedcaseclassnames# do not ignore non-public library class-dontskipnonpubliclibraryclasses # Optimizes the class file that does not optimize the input-dontoptimize #预校验-dontpreverify the algorithm used to confuse the #混淆时是否记录日志-verbose #-optimizations!code/simplification/ arithmetic,!field/*,!class/merging/* #保护注解-keepattributes *annotation*# Keep What classes are not confused #-keep public class * extends android.app.fragment# If you have a reference V4 package you can add the following line-keep public class * extends android.support.v4.app.fragment# Ignore warning-ignorewarning#################### #记录生成的日志数据, gradle build at the root of this project output ################ #apk The internal structure of all classes within the package-dump class_files.txt# non-confusing classes and members-printseeds seeds.txt# lists the code removed from the APK-printusage unused.txt# confusion before and after the mappings-printmapping mapping.txt #################### #记录生成的日志数据, gradle build is output at the root of this project-end################################ Confusing part of the code that protects your project and the referenced third-party jar package Library##########################-libraryjars Libs/xutils-2.6.14.jar#-libraryjars libs/ Alipaysdk.jar#-libraryjars Libs/alipaysecsdk.jar#-libraryjars Libs/alipayutdid.jar#-libraryjars libs/ Wup-1.0.0-snapshot.jar#-libraryjarslibs/weibosdkcore.jar# Samsung App market needs to be added: Sdk-v1.0.0.jar,look-v1.0.1.jar#-libraryjars libs/sdk-v1.0.0.jar#-libraryjars libs/look-v1.0.1.jar# I refer to a picture loading frame in the form of Libaray, if you do not want to confuse keep off-keep class com.nostra13.universalimageloader.** {*;} #忽略警告-dontwarn com.veidy.mobile.common.** #保留一个完整的包-keep class com.veidy.mobile.common.** {*;} #如果引用了v4或者v7包-dontwarn android.support.**########### #混淆保护自己项目的部分代码以及引用的第三方jar包library-end###################-  Keep public class * extends Android.view.View {# public<Init>(Android.content.Context); # Public<Init>(Android.content.Context, android.util.AttributeSet);<Init>(Android.content.Context, android.util.AttributeSet, int); # public void set* (...); #} #保持 Native method is not confused-keepclasseswithmembernames class * {native<Methods>;} #保持自定义控件类不被混淆 #-keepclasseswithmembers class * {# public<Init>(Android.content.Context, Android.util.AttributeSet); #} #保持自定义控件类不被混淆 #-keepclasseswithmembers class * {# public ' /c6><Init>(Android.content.Context, android.util.AttributeSet, int); #} #保持自定义控件类不被混淆 #-keepclassmembers class * extends android.app.Activity {# public void * (Android.view.View); #} #保持 parcelable not be confused-keep class * Implements Android.os.Parcel Able {public static final Android.os.parcelable$creator *;} #保持 Serializable not be confused-keepnames class * Implements java.io.serializable# keep Serializable not be confused and enum    Class is also not confused-keepclassmembers class * Implements Java.io.Serializable {static final long serialversionuid;    private static final java.io.objectstreamfield[] Serialpersistentfields; !static!transient< Fields>; !private< Fields>; !private<Methods>;    private void WriteObject (Java.io.ObjectOutputStream);    private void ReadObject (Java.io.ObjectInputStream);    Java.lang.Object Writereplace (); Java.lang.Object readresolve ();}   #保持枚举 enum class is not confused if you confuse an error, it is recommended to use the-keepclassmembers class * implements java.io.Serializable above to #-keepclassmembers enum * {# public static **[] values (), public static * * VALUEOF (java.lang.String), #}-keepclassmembers class * {public void * ButtonClicked (Android.view.View);} #不混淆资源类-keepclassmembers class * *. r$* {public static< Fields>;} #避免混淆泛型 If the confusion of the error is recommended to switch off #–keepattributes signature# Remove the log test is not used or recommend that you define a switch to control whether the output log-assumenosideeffects class    Android.util.Log {public static Boolean isloggable (java.lang.String, int);    public static int V (...);    public static int I (...);    public static int W (...);    public static int d (...);  public static int E (...);} 

Questions about how Android Studio uses code 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.