feat: android代码混淆
This commit is contained in:
parent
e9d4a0bf72
commit
105f029470
13
android/app/and_res_guard.gradle
Normal file
13
android/app/and_res_guard.gradle
Normal file
@ -0,0 +1,13 @@
|
||||
apply plugin: 'AndResGuard'
|
||||
|
||||
andResGuard {
|
||||
whiteList = [
|
||||
"R.xml.jpush*",
|
||||
"R.drawable.jpush*",
|
||||
"R.layout.jpush*",
|
||||
"R.layout.push*",
|
||||
"R.string.jg*",
|
||||
"R.style.MyDialogStyle",
|
||||
"R.style.JPushTheme"
|
||||
]
|
||||
}
|
||||
@ -28,6 +28,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'android-junk-code'
|
||||
apply plugin: 'com.huawei.agconnect'
|
||||
apply from: 'and_res_guard.gradle'
|
||||
|
||||
androidJunkCode {
|
||||
variantConfig {
|
||||
@ -52,10 +53,10 @@ android {
|
||||
// 这里“debug”不是一个自定义变量,而是一个特定的关键词,凡是使用--debug模式,都会引用到这里
|
||||
// 目前看来,debug模式没办法在buildTypes里面按flavors指定编译签名,所有口味的debug模式只能用同一个签名
|
||||
debug {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
// storeFile file("xhj.jks")
|
||||
// storePassword 'xhj8872'
|
||||
// keyAlias = 'upload'
|
||||
@ -122,7 +123,7 @@ android {
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
lintOptions{
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
@ -167,7 +168,7 @@ android {
|
||||
JPUSH_PKGNAME : "这里不重要,在口味配置",
|
||||
//JPush 上注册的包名对应的 Appkey.
|
||||
// JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey
|
||||
JPUSH_APPKEY : "251fc8074820d122b6de58d2",//--鑫泓佳AppKey
|
||||
JPUSH_APPKEY : "251fc8074820d122b6de58d2",//--鑫泓佳AppKey
|
||||
JPUSH_CHANNEL : "flutter_channel",
|
||||
|
||||
//若不集成厂商通道,可直接跳过以下配置
|
||||
@ -175,14 +176,23 @@ android {
|
||||
// XIAOMI_APPID : "MI-2882303761520287291",
|
||||
// XIAOMI_APPKEY : "MI-5352028744291",
|
||||
//以下均为鑫泓佳的配置
|
||||
XIAOMI_APPID : "MI-2882303761520314939",
|
||||
XIAOMI_APPID : "MI-2882303761520314939",
|
||||
XIAOMI_APPKEY : "MI-5312031456939",
|
||||
<<<<<<< Updated upstream
|
||||
OPPO_APPKEY : "OP-47f668c9943248118502aa58d066393b",
|
||||
OPPO_APPID : "OP-31726001",
|
||||
OPPO_APPSECRET : "OP-05723986bba64183a71530b496922450",
|
||||
// VIVO_APPKEY : "vivo的APPKEY",
|
||||
// VIVO_APPID : "vivo的APPID",
|
||||
HONOR_APPID : "110798531",
|
||||
=======
|
||||
OPPO_APPKEY : "OP-47f668c9943248118502aa58d066393b",
|
||||
OPPO_APPID : "OP-31726001",
|
||||
OPPO_APPSECRET: "OP-05723986bba64183a71530b496922450",
|
||||
VIVO_APPKEY : "75fe8e570425b714e08d0390b14797cb",
|
||||
VIVO_APPID : "105752244",
|
||||
HONOR_APPID : "104458196",
|
||||
>>>>>>> Stashed changes
|
||||
]
|
||||
splits {
|
||||
abi {
|
||||
@ -202,25 +212,27 @@ android {
|
||||
// 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210)
|
||||
// 为release模式设置混淆可以解决地图闪退问题
|
||||
// 真实的解决办法
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
productFlavors.local.signingConfig signingConfigs.debug
|
||||
productFlavors.dev.signingConfig signingConfigs.debug
|
||||
productFlavors.pre.signingConfig signingConfigs.debug
|
||||
productFlavors.sky.signingConfig signingConfigs.sky
|
||||
productFlavors.xhj.signingConfig signingConfigs.xhj
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
release {
|
||||
// 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210)
|
||||
// 为release模式设置混淆可以解决地图闪退问题
|
||||
// 真实的解决办法
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
productFlavors.local.signingConfig signingConfigs.debug
|
||||
productFlavors.dev.signingConfig signingConfigs.debug
|
||||
productFlavors.pre.signingConfig signingConfigs.debug
|
||||
productFlavors.sky.signingConfig signingConfigs.sky
|
||||
productFlavors.xhj.signingConfig signingConfigs.xhj
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,10 +256,19 @@ dependencies {
|
||||
//接入OPPO厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:oppo:5.2.3'
|
||||
//引入 libs 中的 aar,如果项目中有此依赖不需要重复引用
|
||||
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
//OPPO 3.1.0 aar 及其以上版本需要添加以下依赖
|
||||
implementation 'com.google.code.gson:gson:2.6.2'
|
||||
implementation 'commons-codec:commons-codec:1.6'
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
<<<<<<< Updated upstream
|
||||
|
||||
=======
|
||||
// 接入荣耀厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:honor:5.2.3'
|
||||
//需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
|
||||
// implementation(name: 'HiPushSDK-7.0.61.303', ext: 'aar')
|
||||
//接入 VIVO 厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:vivo:5.2.3'
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
125
android/app/proguard-android.txt
Normal file
125
android/app/proguard-android.txt
Normal file
@ -0,0 +1,125 @@
|
||||
#Flutter Wrapper
|
||||
-keep class io.flutter.app.** { *; }
|
||||
-keep class io.flutter.plugin.** { *; }
|
||||
-keep class io.flutter.util.** { *; }
|
||||
-keep class io.flutter.view.** { *; }
|
||||
-keep class io.flutter.** { *; }
|
||||
-keep class io.flutter.plugins.** { *; }
|
||||
|
||||
-keepattributes Signature
|
||||
-keepattributes InnerClasses,EnclosingMethod
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-dontwarn com.hwangjr.rxbus.**
|
||||
-keep class com.hwangjr.rxbus.** { *; }
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Retain generic type information for use by reflection by converters and adapters.
|
||||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
|
||||
-dontwarn com.jcraft.jzlib.**
|
||||
-keep class com.jcraft.jzlib.** { *;}
|
||||
|
||||
-dontwarn sun.misc.**
|
||||
-keep class sun.misc.** { *;}
|
||||
|
||||
-dontwarn retrofit2.**
|
||||
-keep class retrofit2.** { *;}
|
||||
|
||||
-dontwarn io.reactivex.**
|
||||
-keep class io.reactivex.** { *;}
|
||||
|
||||
-dontwarn sun.security.**
|
||||
-keep class sun.security.** { *; }
|
||||
|
||||
-dontwarn com.google.**
|
||||
-keep class com.google.** { *;}
|
||||
|
||||
-keep public class android.net.http.SslError
|
||||
-keep public class android.webkit.WebViewClient
|
||||
|
||||
-dontwarn android.webkit.WebView
|
||||
-dontwarn android.net.http.SslError
|
||||
-dontwarn android.webkit.WebViewClient
|
||||
|
||||
-dontwarn android.support.**
|
||||
|
||||
-dontwarn org.apache.**
|
||||
-keep class org.apache.** { *;}
|
||||
|
||||
-dontwarn okhttp3.**
|
||||
-keep class okhttp3.** { *;}
|
||||
-keep interface okhttp3.** { *; }
|
||||
|
||||
-dontwarn okio.**
|
||||
-keep class okio.** { *;}
|
||||
|
||||
-keep class **JNI* {*;}
|
||||
|
||||
-keep class com.lib.flutter_blue_plus.* { *; }
|
||||
|
||||
-ignorewarnings
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes Exceptions
|
||||
-keepattributes InnerClasses
|
||||
-keepattributes Signature
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-keep class com.huawei.hianalytics.**{*;}
|
||||
-keep class com.huawei.updatesdk.**{*;}
|
||||
-keep class com.huawei.hms.**{*;}
|
||||
|
||||
-keep class cn.ones.project.push.receiver.OnesMiMessageReceiver {*;}
|
||||
|
||||
-keep public class * extends android.app.Service
|
||||
-keep class com.heytap.msp.** { *;}
|
||||
|
||||
-dontwarn com.vivo.push.**
|
||||
-keep class com.vivo.push.**{*; }
|
||||
-keep class com.vivo.vms.**{*; }
|
||||
-keep class cn.ones.project.push.receiver.OnesVivoPushMessageReceiver {*;}
|
||||
|
||||
|
||||
-dontoptimize
|
||||
-dontpreverify
|
||||
-dontwarn cn.jpush.**
|
||||
-keep class cn.jpush.** { *; }
|
||||
-keep class * extends cn.jpush.android.service.JPushMessageService { *; }
|
||||
-dontwarn cn.jiguang.**
|
||||
-keep class cn.jiguang.** { *; }
|
||||
|
||||
-dontwarn com.google.**
|
||||
-keep class com.google.gson.** {*;}
|
||||
-keep class com.google.protobuf.** {*;}
|
||||
|
||||
-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.**{*;}
|
||||
|
||||
-keep class com.amap.api.maps2d.**{*;}
|
||||
-keep class com.amap.api.mapcore2d.**{*;}
|
||||
|
||||
-keep class com.amap.api.navi.**{*;}
|
||||
|
||||
|
||||
-keep class com.alipay.deviceid.** { *; }
|
||||
-keep class net.security.device.api.** {*;}
|
||||
-keep class org.json.** { *;}
|
||||
-keep class com.alibaba.fastjson.** {*;}
|
||||
-keep class com.alibaba.sdk.android.oss.** { *; }
|
||||
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.apache.commons.codec.binary.**
|
||||
|
||||
-keepclassmembers,allowobfuscation class * {
|
||||
@com.alibaba.fastjson.annotation.JSONField <fields>;
|
||||
}
|
||||
@ -22,6 +22,7 @@ buildscript {
|
||||
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
|
||||
// 垃圾代码生成器
|
||||
classpath "com.github.qq549631030:android-junk-code:1.3.3"
|
||||
classpath'com.tencent.mm:AndResGuard-gradle-plugin:1.2.21'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
android.enableJetifier=false
|
||||
android.enableR8 = true
|
||||
Loading…
x
Reference in New Issue
Block a user