日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

【Android 安全】DEX 加密 ( Proguard 简介 | 默认 ProGuard 分析 )

發(fā)布時(shí)間:2025/6/17 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Android 安全】DEX 加密 ( Proguard 简介 | 默认 ProGuard 分析 ) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

  • 一、Proguard 配置簡介
  • 二、Proguard 完整注釋





一、Proguard 配置簡介



更多 ProGuard 混淆配置參考 : https://www.guardsquare.com/en/products/proguard/manual/usage


1 . 不進(jìn)行優(yōu)化 :

# 不要進(jìn)行優(yōu)化 -dontoptimize

2 . 混淆大小寫 : 不要使用混合大小寫類名進(jìn)行混淆 , 混淆后的名稱全部都是小寫 , 增加閱讀難度

# 不要使用混合大小寫類名進(jìn)行混淆 , 混淆后的名稱全部都是小寫 , 增加閱讀難度 -dontusemixedcaseclassnames

3 . 保留反射屬性 : 保留一些反射中可能用到的屬性

# 保留一些反射中可能用到的屬性 -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod

4 . 保留這些類和類成員 :

# 保留這些類和類成員 -keep public class com.google.vending.licensing.ILicensingService

5 . 控制日志輸出 : -dontnote , 控制編譯時(shí)不在 Build 對話框輸出一些日志信息 ;

# 控制編譯時(shí)不在 Build 對話框輸出一些日志信息 -dontnote com.android.vending.licensing.ILicensingService

6 . Native 函數(shù)混淆設(shè)置 :

# 不混淆 Native 函數(shù) # http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * {native <methods>; }

7 . 保留類成員 , 包括成員函數(shù) 和 成員變量 :

# 不要混淆 Activity 及 子類的 成員 , 以防在 XML 的 onCLick 屬性中用到 . -keepclassmembers class * extends android.app.Activity {public void *(android.view.View); }

8 . 保留注解 : 保留 android.support.annotation.Keep 注解類 , 不被混淆 ;

# 保留注解 -keep class android.support.annotation.Keep

9 . 保留被注解聲明的類 : 被 @android.support.annotation.Keep 注解修飾的類不被混淆 ;

# 保留被 @android.support.annotation 注解聲明的類 -keep @android.support.annotation.Keep class * {*;}

10 . 保留被注解聲明的函數(shù) : 被 @android.support.annotation.Keep 注解修飾的函數(shù)不被混淆 ;

# 保留被 @android.support.annotation 注解聲明的函數(shù) -keepclasseswithmembers class * {@android.support.annotation.Keep <methods>; }

11 . 保留被注解聲明的成員 : 被 @android.support.annotation.Keep 注解修改的成員 , 不會被混淆 ;

# 保留被 @android.support.annotation 注解聲明的成員 -keepclasseswithmembers class * {@android.support.annotation.Keep <fields>; }

12 . 保留被注解聲明的構(gòu)造函數(shù) : 被 @android.support.annotation.Keep 修飾的構(gòu)造函數(shù)不會被混淆 ;

# 保留被 @android.support.annotation 注解聲明的構(gòu)造函數(shù) -keepclasseswithmembers class * {@android.support.annotation.Keep <init>(...); }



二、Proguard 完整注釋



# This is a configuration file for ProGuard. # http://proguard.sourceforge.net/index.html#manual/usage.html # # 從 Gradle 插件 2.2 版本開始 , 該文件與插件一同發(fā)布, 在編譯構(gòu)建時(shí)取出 . # 不再維護(hù) $ANDROID_HOME 中的文件 , 新的 Gradle 插件版本將會忽略這些文件 . # # 默認(rèn)情況下 , 優(yōu)化會被關(guān)閉 . # Dex 自己會執(zhí)行優(yōu)化 , 不建議在 ProGuard 步驟中進(jìn)行優(yōu)化 . # 如果想要啟用優(yōu)化 , 不能只在 ProGuard 項(xiàng)目配置中將優(yōu)化標(biāo)志設(shè)為 true ; # 相反還要在 build.gradle 中指向 "proguard-android-optimize.txt" 文件 . # 不要進(jìn)行優(yōu)化 -dontoptimize# 不要使用混合大小寫類名進(jìn)行混淆 , 混淆后的名稱全部都是小寫 , 增加閱讀難度 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -verbose# 保留一些反射中可能用到的屬性 -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod# 保留這些類和類成員 -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService -keep public class com.google.android.vending.licensing.ILicensingService # 控制編譯時(shí)不在 Build 對話框輸出一些日志信息 -dontnote com.android.vending.licensing.ILicensingService -dontnote com.google.vending.licensing.ILicensingService -dontnote com.google.android.vending.licensing.ILicensingService# 不混淆 Native 函數(shù) # http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * {native <methods>; }# 不要混淆繼承自 View 的 get set 函數(shù) , 以便讓動畫可以繼續(xù)工作 # 指定類成員 ( 成員方法 / 成員變量 ) 不被混淆 -keepclassmembers public class * extends android.view.View {void set*(***);*** get*(); }# 不要混淆 Activity 及 子類的 成員 , 以防在 XML 的 onCLick 屬性中用到 . -keepclassmembers class * extends android.app.Activity {public void *(android.view.View); }# 枚舉成員不要混淆 # http://proguard.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * {public static **[] values();public static ** valueOf(java.lang.String); }-keepclassmembers class * implements android.os.Parcelable {public static final ** CREATOR; }-keepclassmembers class **.R$* {public static <fields>; }# Preserve annotated Javascript interface methods. -keepclassmembers class * {@android.webkit.JavascriptInterface <methods>; }# The support libraries contains references to newer platform versions. # Don't warn about those in case this app is linking against an older # platform version. We know about them, and they are safe. -dontnote android.support.** -dontnote androidx.** -dontwarn android.support.** -dontwarn androidx.**# This class is deprecated, but remains for backward compatibility. -dontwarn android.util.FloatMath# Understand the @Keep support annotation. # 保留注解 -keep class android.support.annotation.Keep -keep class androidx.annotation.Keep# 保留被 @android.support.annotation 注解聲明的類 -keep @android.support.annotation.Keep class * {*;} # 保留被 @androidx.annotation 注解聲明的類 -keep @androidx.annotation.Keep class * {*;}# 保留被 @android.support.annotation 注解聲明的函數(shù) -keepclasseswithmembers class * {@android.support.annotation.Keep <methods>; } # 保留被 @androidx.annotation 注解聲明的函數(shù) -keepclasseswithmembers class * {@androidx.annotation.Keep <methods>; }# 保留被 @android.support.annotation 注解聲明的成員 -keepclasseswithmembers class * {@android.support.annotation.Keep <fields>; }# 保留被 @androidx.annotation 注解聲明的成員 -keepclasseswithmembers class * {@androidx.annotation.Keep <fields>; }# 保留被 @android.support.annotation 注解聲明的構(gòu)造函數(shù) -keepclasseswithmembers class * {@android.support.annotation.Keep <init>(...); }# 保留被 @androidx.annotation 注解聲明的構(gòu)造方法 -keepclasseswithmembers class * {@androidx.annotation.Keep <init>(...); }# These classes are duplicated between android.jar and org.apache.http.legacy.jar. -dontnote org.apache.http.** -dontnote android.net.http.**# These classes are duplicated between android.jar and core-lambda-stubs.jar. -dontnote java.lang.invoke.**

總結(jié)

以上是生活随笔為你收集整理的【Android 安全】DEX 加密 ( Proguard 简介 | 默认 ProGuard 分析 )的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。