Flutter-APP打包流程

Android版

一.创建Flutter的打包秘钥(生成.jks文件)

打来命令执行框cmd,输入一下命令 或  在AS的终端中,进入到工程目录输入(根据实际情况修改~/key.jks

keytool -genkey -v -keystore D:\flutterDemo\key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
 Flutter-APP打包流程_第1张图片

二、Android的Gradle打包配置

① 创建key.properities

android目录下创建一个文件,文件名为:`key.properties'
文件内容为:

storeFile = ../app/flutterapp.jks
storePassword = fapp2020
keyAlias = flutterapp
keyPassword = fapp2020

 注意:keyAlias = key

②/android/app/build.gradle文件中配置

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


android {
.......

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']

        }

    }

    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.release
        }
    }
}

三、通过命令快速打包

1.使用命令行进入项目所在的根目录

2.在根目录下面执行以下命令:

运行flutter build apk(flutter build 默认会包含 --release选项)

3.经过一系列编译打包流程,最后打包好的发布APK位于/build/app/outputs/apk/app-release.apk。


 参考:https://juejin.im/post/6844903753498247182

你可能感兴趣的