Skip to content

Commit 7e64d97

Browse files
committed
feat: 安卓平台混淆设置
1 parent db400e1 commit 7e64d97

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

android/app/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ android {
4545
versionCode flutterVersionCode.toInteger()
4646
versionName flutterVersionName
4747
ndk {
48-
// abiFilters "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
48+
abiFilters "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
4949
// TODO 只打包flutter所支持的架构,flutter没有armeabi架构的so,加x86的原因是为了能够兼容模拟器
50-
abiFilters "armeabi-v7a" // release 时只打"armeabi-v7包
50+
// abiFilters "armeabi-v7a" // release 时只打"armeabi-v7包
5151
}
5252
}
5353

@@ -64,9 +64,11 @@ android {
6464
release {
6565
// TODO: Add your own signing config for the release build.
6666
// Signing with the debug keys for now, so `flutter run --release` works.
67-
//关闭混淆
68-
minifyEnabled false // 删除无用代码
69-
shrinkResources false // 删除无用资源
67+
// 开启混淆
68+
minifyEnabled true // 启用代码混淆、压缩APK
69+
shrinkResources true // 删除无用资源
70+
useProguard true // 代码压缩设置
71+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // 混淆文件
7072
signingConfig signingConfigs.release
7173
}
7274
}

android/app/proguard-rules.pro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Flutter Wrapper
2+
-dontwarn io.flutter.**
3+
-keep class io.flutter.app.** { *; }
4+
-keep class io.flutter.plugin.** { *; }
5+
-keep class io.flutter.util.** { *; }
6+
-keep class io.flutter.view.** { *; }
7+
-keep class io.flutter.** { *; }
8+
-keep class io.flutter.plugins.** { *; }
9+
#友盟
10+
-keep class com.umeng.** {*;}
11+
-keepclassmembers class * {
12+
public <init> (org.json.JSONObject);
13+
}
14+
-keepclassmembers enum * {
15+
public static **[] values();
16+
public static ** valueOf(java.lang.String);
17+
}
18+
-keep public class [com.wkl.flutter_trip].R$*{
19+
public static final int *;
20+
}

0 commit comments

Comments
 (0)