Flutter Android 打包App
1、检查App Manifest
更改应用名称和应用图标
<app dir>/android/app/src/main/AndroidManifest.xml
//是用来设置所有activity属于哪个application的,默认是android.app.Application。android:name='io.flutter.app.FlutterApplication'//app 显示名android:label='test_app'//app 图标android:icon='@mipmap/ic_launcher'>
2、查看构建配置
<app dir>/android/app/build.gradle
defaultConfig:applicationId: 指定始终唯一的 (Application Id)appidversionCode & versionName: 指定应用程序版本号和版本号字符串。minSdkVersion & targetSdkVersion: 指定最低的API级别以及应用程序设计运行的API级别。
3、添加启动图标
<app dir>/android/app/src/main/res/mipmap-****
4、app签名
1)、创建keystore
如果存在keystore请跳至下一步。
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
改为
keytool -genkey -v -keystore e:\key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key


2)、引用应用程序中的keystore
创建 <app dir>/android/key.properties 文件
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, e.g. /Users/<user name>/key.jks>
3)、gradle中配置签名
<app dir>/android/app/build.gradle
android {上添加def keystorePropertiesFile = rootProject.file('key.properties')def keystoreProperties = new Properties()keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
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}}替换为signingConfigs {release {keyAlias keystoreProperties['keyAlias']keyPassword keystoreProperties['keyPassword']storeFile file(keystoreProperties['storeFile'])storePassword keystoreProperties['storePassword']}}buildTypes {release {signingConfig signingConfigs.release}}
5、打包apk
flutter build apk

打好包的发布apk位于 <app dir>/build/app/outputs/apk/release/app-release.apk

