用flutter发布Android app 一般需要以下步骤(不包括发布到应用商店)
- 将应用图标放入 - <app dir>/android/app/src/main/res/目录
- 检查 - <app dir>/android/app/src/main/AndroidManifest.xml,修改- package,- application-android:label,- application-android-icon
- 修改 - <app dir>/android/app/src/main/kotlin下文件结构,并将其下- MainActivity.kt第一行修改为包名
- 把文件 - key.properties复制到- <app dir>/android目录下
- 修改 - <app dir>/android/app/build.gradle- 替换 - 1 - android{ - 为 - 1 
 2
 3
 4
 5- def keystorePropertiesFile = rootProject.file("key.properties") 
 def keystoreProperties = new Properties()
 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
 android{
- 替换 - 1 
 2
 3
 4
 5
 6
 7- buildTypes { 
 release {
 // TODO: Add your own signing config for the release build.
 // Signing with the debug keys for now, so `flutter run --release` works.
 signingConfig signingConfigs.debug
 }
 }- 为 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13- signingConfigs { 
 release {
 keyAlias keystoreProperties['keyAlias']
 keyPassword keystoreProperties['keyPassword']
 storeFile file(keystoreProperties['storeFile'])
 storePassword keystoreProperties['storePassword']
 }
 }
 buildTypes {
 release {
 signingConfig signingConfigs.release
 }
 }
- 修改 - defaultConfig中- applicationId
 
- 生成apk文件 - 1 - flutter build apk --target-platform android-arm64 - 文件位于 - <app dir>/build/app/outputs/apk/app-release.apk
未签名应用签名方式:
| 1 | jarsigner -verbose -keystore C:\Users\yzsu0\key.jks -signedjar signed.apk no_sign.apk key |