1.创建签名
'''keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key'''
WeChat2587389f7ab2415900cf7fac6e2866de.png
-keystore:生成的jks文件路径;
-alias:项目别名,自己可定制;
-validity:有效期(天);
2.引用应用程序中当jks
WeChata5e73e40812b9547b83db5f95e64a71a.png
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks
3.build.gradle里面添加如下代码:
// 代码配置在android节点的上面
def keystorePropertiesFile=rootProject.file('key.properties')
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
// buildTypes节点上面配置
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
WeChat5c5bcea98dd6ad0e3f839c00c9fd141f.png
4.最后在工程目录下输入
flutter build apk
WeChat82785a64b846d081a65ec49a0532c365.png
build/app/outputs/apk/release/app-release.apk 目录就是已经打包好的apk了。
网友评论