Skip to content

Commit 6378dcf

Browse files
committed
feat: 打包发布
1 parent b95d94c commit 6378dcf

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
**/android/gradlew.bat
3636
**/android/local.properties
3737
**/android/**/GeneratedPluginRegistrant.java
38+
**/android/key.properties
3839

3940
# iOS/XCode related
4041
**/ios/**/*.mode1v3

android/app/build.gradle

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if (flutterVersionName == null) {
2424
apply plugin: 'com.android.application'
2525
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

27+
// 密钥
28+
def keystorePropertiesFile = rootProject.file("key.properties")
29+
def keystoreProperties = new Properties()
30+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
31+
2732
android {
2833
compileSdkVersion 28
2934

@@ -40,12 +45,26 @@ android {
4045
versionName flutterVersionName
4146
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
4247
}
43-
48+
// 配置安卓打包
49+
signingConfigs {
50+
release {
51+
keyAlias keystoreProperties['keyAlias']
52+
keyPassword keystoreProperties['keyPassword']
53+
storeFile file(keystoreProperties['storeFile'])
54+
storePassword keystoreProperties['storePassword']
55+
}
56+
}
4457
buildTypes {
4558
release {
4659
// TODO: Add your own signing config for the release build.
4760
// Signing with the debug keys for now, so `flutter run --release` works.
48-
signingConfig signingConfigs.debug
61+
// signingConfig signingConfigs.debug
62+
// 正式环境打包,配置混淆压缩
63+
signingConfig signingConfigs.release
64+
minifyEnabled true
65+
useProguard true
66+
67+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4968
}
5069
}
5170
}

android/app/proguard-rules.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Flutter Wrapper
2+
-keep class io.flutter.app.** { *; }
3+
-keep class io.flutter.plugin.** { *; }
4+
-keep class io.flutter.util.** { *; }
5+
-keep class io.flutter.view.** { *; }
6+
-keep class io.flutter.** { *; }
7+
-keep class io.flutter.plugins.** { *; }

0 commit comments

Comments
 (0)