项目信息
系统:MacOS
开发工具:Visual Studio Code
Flutter版本: 3.22.1
生成 签名密钥库(keystore)
keytool -genkey -v -keystore ~/development/keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias ziqiong_music
要求输入密码、信息等
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: duanziqiong
What is the name of your organizational unit?
[Unknown]: NA
What is the name of your organization?
[Unknown]: duanziqiong
What is the name of your City or Locality?
[Unknown]: Beijing
What is the name of your State or Province?
[Unknown]: Beijing
What is the two-letter country code for this unit?
[Unknown]: CN
Is CN=duanziqiong, OU=NA, O=duanziqiong, L=Beijing, ST=Beijing, C=CN correct?
[no]: yes
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
for: CN=duanziqiong, OU=NA, O=duanziqiong, L=Beijing, ST=Beijing, C=CN
Enter key password for <ziqiong_music>
(RETURN if same as keystore password):
Re-enter new password:
[Storing /Users/ran/development/keystore.jks]
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /Users/ran/development/keystore.jks -destkeystore /Users/ran/development/keystore.jks -deststoretype pkcs12".
配置
在文件`android/app/build.gradle`中配置
android {
// ******
signingConfigs {
release {
keyAlias 'ziqiong_music'
keyPassword '******'
storeFile file('/Users/ran/development/keystore.jks')
storePassword '******'
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// ******
}
构建
执行 flutter build apk --release
输出 build/app/outputs/flutter-apk/app-release.apk
安装
指定设备 flutter install -d 2B101FDH200FLK
选择设备 flutter install