Flutter打包发布

terminal执行下列命令:
1.生成key(如果有现成的Key跳过这一步)

输入命令:keytool -genkey -v -keystore D:\git_boyacx\AndroidGit\flutter_study-master/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key 如下图

Flutter打包发布_第1张图片

2.key.properties创建

在android目录下创建此文件后设置密码,

storePassword= //输入上一步创建KEY时输入的 密钥库 密码 keyPassword= //输入上一步创建KEY时输入的 密钥 密码 keyAlias=key storeFile= //key.jks的存放路径

如图:

Flutter打包发布_第2张图片

3.配置key注册

进入项目目录的/android/app/build.gradle文件,在android {这一行前面,加入如下代码:

//apk打包配置

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 {

        // 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

    }

}

如下图:

Flutter打包发布_第3张图片

4.执行flutter build apk

如下图:

Flutter打包发布_第4张图片

 

 

你可能感兴趣的:(Flutter打包发布)