Android代码混淆模板
发布日期:2021-05-27 02:49:04
浏览次数:24
分类:技术文章
本文共 5647 字,大约阅读时间需要 18 分钟。
# Add project specific ProGuard rules here.# You can control the set of applied configuration files using the# proguardFiles setting in build.gradle.## For more details, see# http://developer.android.com/guide/developing/tools/proguard.html# If your project uses WebView with JS, uncomment the following# and specify the fully qualified class name to the JavaScript interface# class:#-keepclassmembers class fqcn.of.javascript.interface.for.webview {# public *;#}# Uncomment this to preserve the line number information for# debugging stack traces.#-keepattributes SourceFile,LineNumberTable# If you keep the line number information, uncomment this to# hide the original source file name.#-renamesourcefileattribute SourceFile#指定压缩级别-optimizationpasses 5#不跳过非公共的库的类成员-dontskipnonpubliclibraryclassmembers#混淆时采用的算法-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*#把混淆类中的方法名也混淆了-useuniqueclassmembernames#优化时允许访问并修改有修饰符的类和类的成员-allowaccessmodification#将文件来源重命名为“SourceFile”字符串-renamesourcefileattribute SourceFile#保留行号-keepattributes SourceFile,LineNumberTable-keepattributes *Annotation*,InnerClasses #保留注解不混淆-keepattributes Signature # 避免混淆泛型-keepattributes SourceFile,LineNumberTable# 抛出异常时保留代码行号#混淆时不使用大小写混合类名-dontusemixedcaseclassnames#不跳过library中的非public的类-dontskipnonpubliclibraryclasses#打印混淆的详细信息-verbose#保留native方法的类名和方法名-keepclasseswithmembernames class * { native;}#--------------------------------------------- 公共配置 End ----------------------------------------##保持所有实现 Serializable 接口的类成员-keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve();}#所有实体类都保持住-keep public class com.xxx.models.** {*;}#Fragment不需要在AndroidManifest.xml中注册,需要额外保护下-keep public class * extends android.support.v4.app.Fragment-keep public class * extends android.app.Fragment-keep public class * extends android.app.Activity-keep public class * extends android.app.Application-keep public class * extends android.support.multidex.MultiDexApplication-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.Preference-keep public class * extends android.view.View-keep public class * extends com.plan_solve.farmlandassistant.activitys.CheckPermissionsActivity-keep class android.support.** {*;}## 保留support下的所有类及其内部类# 保留我们自定义控件(继承自View)不被混淆-keep public class * extends android.view.View{ *** get*(); void set*(***); public (android.content.Context); public (android.content.Context, android.util.AttributeSet); public (android.content.Context, android.util.AttributeSet, int);}#webView需要进行特殊处理-keepclassmembers class com.plan_solve.farmlandassistant.activitys.indent.MyWebViewActivity { public *;}-keepclassmembers class * extends android.webkit.WebViewClient { public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap); public boolean *(android.webkit.WebView, java.lang.String);}-keepclassmembers class * extends android.webkit.WebViewClient { public void *(android.webkit.WebView, jav.lang.String);}#在app中与HTML5的JavaScript的交互进行特殊处理 #我们需要确保这些js要调用的原生方法不能够被混淆,于是我们需要做如下处理:#-keepclassmembers class com.ljd.example.JSInterface {# ;#}-keep public class [com.plan_solve.farmlandassistant].R$*{ public static final int *;}-keepclassmembers class * { public (org.json.JSONObject);}-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}#--------------------------2.第三方包-------------------------------################pickerview################https://github.com/zaaach/CityPicker-keep class com.zaaach.citypicker.**{ *;}#https://github.com/crazyandcoder/citypicker-keep class com.lljjcoder.**{ *;}-dontwarn demo.**-keep class demo.**{*;}-dontwarn net.sourceforge.pinyin4j.**-keep class net.sourceforge.pinyin4j.**{*;}-keep class net.sourceforge.pinyin4j.format.**{*;}-keep class net.sourceforge.pinyin4j.format.exception.**{*;}#fastJson-dontwarn com.plan_solve.farmlandassistant.okhttp.**-keep class com.plan_solve.farmlandassistant.okhttp.** { *; }#Gson-keepattributes Signature-keepattributes *Annotation*-keep class sun.misc.Unsafe { *; }-keep class com.google.gson.stream.** { *; }-keep class com.google.gson.examples.android.model.** { *; }-keep class com.google.gson.* { *;}-dontwarn com.google.gson.**# 定位-keep class com.amap.api.location.**{*;}-keep class com.amap.api.fence.**{*;}-keep class com.autonavi.aps.amapapi.model.**{*;}# 搜索-keep class com.amap.api.services.**{*;}# 2D地图-keep class com.amap.api.maps2d.**{*;}-keep class com.amap.api.mapcore2d.**{*;}# 导航-keep class com.amap.api.navi.**{*;}-keep class com.autonavi.**{*;}# 保持测试相关的代码-dontnote junit.framework.**-dontnote junit.runner.**-dontwarn android.test.**-dontwarn android.support.test.**-dontwarn org.junit.**# ============忽略警告,否则打包可能会不成功=============-ignorewarnings##记录生成的日志数据,gradle build时在本项目根目录输出###apk 包内所有 class 的内部结构-dump proguard/class_files.txt#未混淆的类和成员-printseeds proguard/seeds.txt#列出从 apk 中删除的代码-printusage proguard/unused.txt#混淆前后的映射-printmapping proguard/mapping.txt########记录生成的日志数据,gradle build时 在本项目根目录输出-end######
github下载下来的根据它的规则进行混淆
转载地址:https://blog.csdn.net/kururunga/article/details/87797776 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年09月10日 05时43分18秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Mac To Win
2019-06-07
hdu 1506
2019-06-07
USACO 2.4 Fractions to Decimals
2019-06-07
hdu 1178
2019-06-07
nyoj 我排第几个
2019-06-07
unity3d实现Socket
2019-06-07
Asp.Net WebService实例
2019-06-07
联机调试,如何配置局域网内文件服务器
2019-06-07
last modified -- expires 初步解释
2019-06-07
事情做完之后的测试
2019-06-07
svn tree conflicts 解决方法
2019-06-07
[转]三层架构与MVC之间的区别
2019-06-07
【转载】Homebrew 的安装与使用
2019-06-07
short i =1; i=i+1与short i=1; i+=1的区别
2019-06-07
Mybatis代码学习
2019-06-07
c#客户端调用sql server 存储过程速度慢的问题
2019-06-07
数据访问层
2019-06-07
玩转Google开源C++单元测试框架Google Test系列(gtest)(总)
2019-06-07
深度分析代理模式
2019-06-07
HttpServletResponce
2019-06-07