android 混淆
16lz
2021-12-04
优秀文章:http://miqingan2006.blog.163.com/blog/static/88156494201363124524107/
http://blog.chinaunix.net/uid-22816738-id-3966551.html
————————————————————————————————————————————————————————————————————————————
实例:
# To enable ProGuard in your project, edit project.properties# to define the proguard.config property as described in that file.## Add project specific ProGuard rules here.# By default, the flags in this file are appended to flags specified# in ${sdk.dir}/tools/proguard/proguard-android.txt# You can edit the include path and order by changing the ProGuard# include property in project.properties.## For more details, see# http://developer.android.com/guide/developing/tools/proguard.html# Add any project specific keep options here:####################这里是 google默认 不混淆 Activity 、Service ... 类的 子类,自定义View,Android Parcelable,Android R 文件,枚举##############################-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.Preference-keep public class com.android.vending.licensing.ILicensingService-keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet);}-keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int);}-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}################################################1.#####################################################-keep 指定的类和类成员被保留作为 入口。-keep class io.vov.**-keep class io.vov.** { *; }-keep class java.awt.** { *; }-keep class android.support.**{*;}-keep class android.** { *; }####-dontwarn 缺省proguard 会检查每一个引用是否正确,但是第三方库里面往往有些不会用到的类,没有正确引用。如果不配置的话,系统就会报错。-- 忽略混淆时第三方jar包的警告-dontwarn###-dontskipnonpubliclibraryclassmembers 指定不去忽略包可见的库类的成员。 # 是否混淆第三方jar-dontskipnonpubliclibraryclassmembers-dontwarn java.awt.**-dontwarn android.support.**-dontwarn android.**-dontwarn com.baidu.**###libraryjars //引入的第三方jar包 //指定要处理的应用程序jar,war,ear和目录所需要的程序库文件-library libs/pushservice-4.1.0.jar-libraryjars libs/fastjson-1.1.17.jar#################引用微信分享第三库的混淆##################################-ignorewarnings 加入如下语句可以忽略混淆过程中的警告(大部分警告指向android.jar)-ignorewarnings#//1.引入的第三方jar包-libraryjars libs/libammsdk.jar#//2.忽略混淆时第三方jar包的警告, “com.tencent.mm”为包名-dontwarn com.tencent.mm.**# //3.不混淆第三方jar包,“com.samsung.android.sdk.bt.gatt”为包名-keep class com.tencent.mm.** {*;}-keep class com.tencent.mm.sdk.openapi.WXMediaMessage{*;}-keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMMediaMessage$IMediaObject{*;}##################################################### 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 *;#}
混淆之后的图片
二、混淆带有第三方jar包的apk 在proguard-project.txt加上以下三句 -libraryjars ./libs/xx.jar //引入的第三方jar包 -dontwarn com.samsung.android.sdk.bt.gatt.** //忽略混淆时第三方jar包的警告, “com.samsung.android.sdk.bt.gatt”为包名 -keep class com.samsung.android.sdk.bt.gatt.** {*;} //不混淆第三方jar包,“com.samsung.android.sdk.bt.gatt”为包名
更多相关文章
- Android(安卓)问题记录
- WARNING: APP_PLATFORM android-14 is larger than android:minS
- Android(安卓)Studio与HttpClient
- [Android分享] 如何解决Android(安卓)5.0中出现的警告:Service In
- Android如何代码混淆
- Android(安卓)Studio打包设置分支
- Android(安卓)Studio实现代码混淆
- 用ant实现自动打包android(二) -- android代码混淆
- android 防止反编译