flutter 打包到各平台

 一、 android 打包

更换图标和名称

创建秘钥库

mac/linux

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

Windows

keytool -genkey -v -keystore c:UsersUSER_NAMEkey.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key

执行

执行最后输入 y

 home路径下回生成文件

从应用程序引用密钥库

创建一个文件

storePassword=pw
keyPassword=pw
keyAlias=key
storeFile=/Users/meng/key.jks>

密码是刚输入的

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

 在android{ 之前添加

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {

在android里加入

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

打包

命令行输入

flutter build apk

打包时遇见几个错误

错误1

搜了半天没找到解决版本,打开小飞机又 build apk 一下,好了! 

错误2

 这个是因为main函数没在main.dart 文件里,之后我把入口移动到main.dart里。解决了

成功后输出到以下路径

 android目录下的-

二、IOS打包

直接

flutter build ios

切换到xcode

选择平台

distribute app,validate app  选择distribute app

 

 1.上传到苹果商店

2.

3.企业级账号

4.

------

三、Web

1.安装flutter_web的编译工具webdev

flutter pub global activate webdev

设置web可用

flutter config --enable-web

未正式发布

四、Windows

flutter   1.22.0-10.0.pre.380

Dart 2.11.0
flutter config --enable-windows-desktop

用新版本的flutter创建一个app

 生成后有windows文件夹

执行

flutter run

打包

flutter build windows

原文地址:https://www.cnblogs.com/buchizaodian/p/10469128.html