feat: android代码混淆

This commit is contained in:
Liuyf 2024-09-07 20:41:09 +08:00
parent e9d4a0bf72
commit 105f029470
5 changed files with 174 additions and 13 deletions

View 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"
]
}

View File

@ -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
}

View 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>;
}

View File

@ -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'
}
}

View File

@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=false
android.enableR8 = true