1.創(chuàng)建?keystore?
keytool -genkey -v -keystore?d:/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
粗字體可換成自己的路徑
生成成功之后巩趁,d盤(pán)下會(huì)出現(xiàn)??key.jks?這個(gè)文件再姑,代表成功囤攀。
2.創(chuàng)建 key.properties
在 flutter 項(xiàng)目 android 下創(chuàng)建?key.properties
?key.properties?文件內(nèi)容為
storePassword=xxx --創(chuàng)建keystore時(shí)的密碼
keyPassword=xxx --創(chuàng)建keystore時(shí)的密碼
keyAlias=key
storeFile=d:/key.jks? ??--key.jks的路徑
3.修改 android>app>build.gradle?文件
在?buildTypes?上面一行新增?
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes>release?則修改為
signingConfig signingConfigs.release
4.構(gòu)建Android?APK
運(yùn)行flutter build apk?命令
如果成功冗懦,打包好的apk包,會(huì)在?flutter項(xiàng)目?build>app>outputs>apk>release>?目錄內(nèi) ,包名為?app-release.apk
至此。發(fā)布完成