From 68c77e9a3eba725e828396b60b5d155239da8def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=A4=A9?= Date: Tue, 25 Jul 2023 14:12:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=89=E5=8D=93=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=E4=BB=A3=E7=A0=81=E6=B7=B7=E6=B7=86=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E3=80=81=E8=B5=84=E6=BA=90=E5=8E=8B=E7=BC=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 8 ++++++++ android/gradle.properties | 3 +++ android/proguard-rules.pro | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 android/proguard-rules.pro diff --git a/android/app/build.gradle b/android/app/build.gradle index c7f99c0..7cba57e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -72,6 +72,14 @@ android { // Signing with the debug keys for now, so `flutter run --release` works. // signingConfig signingConfigs.debug signingConfig signingConfigs.release + + // 移除项目中未使用的资源(如图片、字体和动画),以减小应用程序的包体积 + shrinkResources true + + minifyEnabled true //资源压缩设置 + // 读取代码压缩配置文件 + // 混淆Android原生代码 启用ProGuard + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } diff --git a/android/gradle.properties b/android/gradle.properties index 3e64fae..ff38923 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -3,6 +3,9 @@ android.useAndroidX=true android.enableJetifier=true #org.gradle.java.home=D\:\\Android\\Android Studio\\jbr +# 混淆 +extra-gen-snapshot-options=--obfuscate + # 配置 VPN 加快下载速度 systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyPort=7890 diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 0000000..33d337c --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1,8 @@ +#Flutter Wrapper +-dontwarn io.flutter.** +-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.** { *; }