Files
VscoolOS/app/proguard-rules.pro
Fanhuitong ef836554ad version:1.0.0
update:增加混淆,优化其他包名
bugfixes:
2024-07-11 17:12:25 +08:00

454 lines
15 KiB
Prolog
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 #指定压缩级别
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* #混淆时采用的算法
-verbose #打印混淆的详细信息
-dontoptimize #关闭优化
-keepattributes *Annotation* #保留注解中的参数
-keepattributes *Annotation*,InnerClasses # 保持注解
-keepattributes Signature # 避免混淆泛型, 这在JSON实体映射时非常重要
-ignorewarnings # 屏蔽警告
-keepattributes SourceFile,LineNumberTable # 抛出异常时保留代码行号
#混淆时不使用大小写混合,混淆后的类名为小写(大小写混淆容易导致class文件相互覆盖
-dontusemixedcaseclassnames
#未混淆的类和成员
-printseeds proguardbuild/print_seeds.txt
#列出从 apk 中删除的代码
-printusage proguardbuild/print_unused.txt
#混淆前后的映射,生成映射文件
-printmapping proguardbuild/print_mapping.txt
# 指定一个文本文件,其中所有有效字词都用作混淆字段和方法名称。
# 默认情况下诸如“a”“b”等短名称用作混淆名称。
# 使用模糊字典,您可以指定保留关键字的列表,或具有外来字符的标识符,
# 例如: 忽略空格,标点符号,重复字和#符号后的注释。
# 注意,模糊字典几乎不改善混淆。 有些编译器可以自动替换它们,并且通过使用更简单的名称再次混淆,可以很简单地撤消该效果。
# 最有用的是指定类文件中通常已经存在的字符串(例如'Code'),从而减少类文件的大小。 仅适用于混淆处理。
#-obfuscationdictionary proguardbuild/pro_package.txt
# 指定一个文本文件,其中所有有效词都用作混淆类名。 与-obfuscationdictionary类似。 仅适用于混淆处理。
#-classobfuscationdictionary proguardbuild/pro_class.txt
# 指定一个文本文件,其中所有有效词都用作混淆包名称。与-obfuscationdictionary类似。 仅适用于混淆处理。
#-packageobfuscationdictionary proguardbuild/pro_func.txt
# -------------------------------基本指令区--------------------------------
#---------------------------------默认保留区---------------------------------
#继承activity,application,service,broadcastReceiver,contentprovider....不进行混淆
-keep public class * extends android.app.Activity
-keep public class * extends androidx.fragment.app.Fragment
-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 * extends android.view.View
-keep class android.support.** {*;}
# androidx 混淆
-keep class com.google.android.material.** {*;}
-keep class androidx.** {*;}
-keep public class * extends androidx.**
-keep interface androidx.** {*;}
-keep class * implements androidx.** {*;}
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
-printconfiguration
-keep,allowobfuscation interface androidx.annotation.Keep
-keep @androidx.annotation.Keep class *
-keepclassmembers class * {@androidx.annotation.Keep *;}
#不混淆View中的set***() 和 get***()方法 以保证属性动画正常工作 某个类中的某个方法不混淆
#自定义View的set get方法 和 构造方法不混淆
-keep public class * extends android.view.View{
*** get*();
void set*(***);
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
#这个主要是在layout 中写的onclick方法android:onclick="onClick",不进行混淆
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
#保持 Serializable 不被混淆
-keepnames class * implements java.io.Serializable
#实现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();
}
# 保留R文件中所有静态字段以保证正确找到每个资源的ID
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
void *(*Event);
}
#保留枚举类中的values和valueOf方法
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#保留Parcelable实现类中的Creator字段以保证Parcelable机制正常工作
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#保持 Parcelable 不被混淆
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#不混淆包含native方法的类的类名以及native方法名
-keepclasseswithmembernames class * {
native<methods>;
}
#避免log打印输出
-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** w(...);
}
#对含有反射类的处理
#--------------------------------默认保留区--------------------------------------------
#----------------------------- WebView(项目中没有可以忽略) -----------------------------
#webView需要进行特殊处理
# WebView
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
-keep public class android.webkit.WebView
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
#在app中与HTML5的JavaScript的交互进行特殊处理
#我们需要确保这些js要调用的原生方法不能够被混淆于是我们需要做如下处理
-keepclassmembers class com.deepocean.tplh5.helper.JsInterfaceHelper {
<methods>;
}
#----------------------------- WebView(项目中没有可以忽略) -----------------------------
#----------------------------- 实体类不可混淆 ------------------------------------------
#添加实体类混淆规则
# Application classes that will be serialized/deserialized over Gson
-keep class **.entity.** { *; }
-keep class **.bean.** { *; }
#----------------------------- 实体类不可混淆 ------------------------------------------
-dontwarn com.xxpatx.os.bean.**
-keep class com.xxpatx.os.bean.**{*;}
-keep class com.xxpatx.os.utils.AppUsedTimeUtils { *; }
-keep class com.xxpatx.os.utils.AppUsedTimeUtils$AppTimeinfo { *; }
-keepclassmembers class com.xxpatx.os.utils.AppUsedTimeUtils.AppTimeinfo {
<fields>;
<methods>;
}
#----------------------------- 第三方类库 ------------------------------------------
#添加第三方类库的混淆规则
#Adjust sdk
-keep class com.adjust.sdk.**{ *; }
-keep class com.google.android.gms.common.ConnectionResult {
int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.**{ *; }
# OkHttp3 去掉缺失类警告
-dontwarn org.bouncycastle.**
-dontwarn org.conscrypt.**
-dontwarn org.openjsse.javax.net.ssl.**
-dontwarn org.openjsse.net.ssl.**
#----------------------------- 第三方类库 ------------------------------------------
#Aria
-dontwarn com.arialyy.aria.**
-keep class com.arialyy.aria.**{*;}
#QWeather
-dontwarn com.qweather.sdk.**
-keep class com.qweather.sdk.**{*;}
#NiceImageView
-dontwarn com.shehuan.niv.**
-keep class com.shehuan.niv.**{*;}
#verification-view
-dontwarn com.tuo.customview.**
-keep class com.tuo.customview.**{*;}
#disklrucache
-dontwarn com.jakewharton.disklrucache.**
-keep class com.jakewharton.disklrucache.**{*;}
#glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {**[] $VALUES; public *;}
#target<27
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
# for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
#-------------- okhttp3 start-------------
# OkHttp3
# https://github.com/square/okhttp
# okhttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.* { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
# okhttp 3
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
# Okio
-dontwarn com.squareup.**
-dontwarn okio.**
-keep public class org.codehaus.* { *; }
-keep public class java.nio.* { *; }
#----------okhttp end--------------
## ---------Retrofit混淆方法---------------
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
# OkHttp3
-dontwarn okhttp3.logging.**
-keep class okhttp3.internal.**{*;}
-dontwarn okio.**
# Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
# RxJava RxAndroid
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
# Gson
-keep class com.google.gson.stream.** { *; }
-keepattributes EnclosingMethod
# Gson
-keep class com.demo.demo1.service.bean.**{*;} # 自定义数据模型的bean目录
# zxing
-dontwarn com.google.zxing.**
-keep class com.google.zxing.** { *; }
# rxlifecycle
-dontwarn com.trello.rxlifecycle4.**
-keep class com.trello.rxlifecycle4.** { *; }
-dontwarn com.trello.lifecycle4.**
-keep class com.trello.lifecycle4.** { *; }
# rxbinding4
-dontwarn com.jakewharton.rxbinding4.**
-keep class com.jakewharton.rxbinding4.** { *; }
# live-event-bus-x
-dontwarn com.jeremyliao.liveeventbus.**
-keep class com.jeremyliao.liveeventbus.** { *; }
-keep class android.arch.lifecycle.** { *; }
-keep class android.arch.core.** { *; }
# facebook rebound
-dontwarn com.facebook.rebound.**
-keep class com.facebook.rebound.** { *; }
#amap start
# 3D 地图 V5.0.0之前:
-keep class com.amap.api.maps.**{*;}
-keep class com.autonavi.amap.mapcore.*{*;}
-keep class com.amap.api.trace.**{*;}
# 3D 地图 V5.0.0之后:
-keep class com.amap.api.maps.**{*;}
-keep class com.autonavi.**{*;}
-keep class com.amap.api.trace.**{*;}
# 定位
-keep class com.amap.api.location.**{*;}
-keep class com.amap.api.fence.**{*;}
-keep class com.loc.**{*;}
-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.**{*;}
#amap end
# mmkv
# Keep all native methods, their classes and any classes in their descriptors
-keepclasseswithmembers,includedescriptorclasses class com.tencent.mmkv.** {
native <methods>;
long nativeHandle;
private static *** onMMKVCRCCheckFail(***);
private static *** onMMKVFileLengthError(***);
private static *** mmkvLogImp(...);
private static *** onContentChangedByOuterProcess(***);
}
# bugly
-dontwarn com.tencent.bugly.**
-keep class com.tencent.bugly.**{*;}
# xcrash
-dontwarn xcrash.**
-keep class xcrash.**{*;}
# aliyun push
-keepclasseswithmembernames class ** {
native <methods>;
}
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.taobao.** {*;}
-keep class com.alibaba.** {*;}
-keep class com.alipay.** {*;}
-keep class com.ut.** {*;}
-keep class com.ta.** {*;}
-keep class anet.**{*;}
-keep class anetwork.**{*;}
-keep class org.android.spdy.**{*;}
-keep class org.android.agoo.**{*;}
-keep class android.os.**{*;}
-keep class org.json.**{*;}
-dontwarn com.taobao.**
-dontwarn com.alibaba.**
-dontwarn com.alipay.**
-dontwarn anet.**
-dontwarn org.android.spdy.**
-dontwarn org.android.agoo.**
-dontwarn anetwork.**
-dontwarn com.ut.**
-dontwarn com.ta.**
# UltimateBarX
-keep class com.zackratos.ultimatebarx.ultimatebarx.** { *; }
-keep class * extends androidx.fragment.app.Fragment { *; }
# MagicIndicator
-dontwarn net.lucode.hackware.**
-keep class net.lucode.hackware.**{*;}
# circleprogressview
-dontwarn com.king.view.circleprogressview.**
-keep class com.king.view.circleprogressview.**{*;}
# jiaozivideoplayer
-keep public class cn.jzvd.JZMediaSystem {*; }
-keep public class cn.jzvd.demo.CustomMedia.CustomMedia {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaIjk {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaSystemAssertFolder {*; }
-keep class tv.danmaku.ijk.media.player.** {*; }
-dontwarn tv.danmaku.ijk.media.player.*
-keep interface tv.danmaku.ijk.media.player.** { *; }
# FFmpegMediaMetadataRetriever
-dontwarn wseemann.media.**
-keep class wseemann.media.**{*;}
# pictureselector start
-keep class com.luck.picture.lib.** { *; }
#// use Camerax
-keep class com.luck.lib.camerax.** { *; }
#// use uCrop
-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }
# pictureselector end
# FlycoTabLayout
-dontwarn com.flyco.tablayout.**
-keep class com.flyco.tablayout.**{ *; }
# Android-PickerView
-dontwarn com.bigkoo.pickerview.**
-keep class com.bigkoo.pickerview.**{ *; }
# LoadingDialog
-dontwarn com.xiasuhuei321.loadingdialog.**
-keep class com.xiasuhuei321.loadingdialog.**{ *; }
# XXPermissions
-keep class com.hjq.permissions.** {*;}
# Toaster
-keep class com.hjq.toast.** {*;}