1.生成签名
按照要求填写,密码不能太简单
keytool -genkeypair -alias debug.keystore -keyalg RSA -validity 36000 -keystore debug.keystore
keytool -genkeypair -alias release.keystore -keyalg RSA -validity 36000 -keystore release.keystore
存放到$cordova的根目录,也就是和www
目录同级,结构如下
- $cordova_root
- www
- build.json
- debug.keystore
- release.keystore
2.添加编译配置,建议使用build.json,存放到Cordova根目录,即和www
目录平级,内容如下
{
"android": {
"debug": {
"keystore": "./debug.keystore",
"alias": "debug.keystore",
"storePassword": "your_debug_pwd",
"password": "your_debug_pwd",
"keystoreType": ""
},
"release": {
"keystore": "./release.keystore",
"alias": "release.keystore",
"storePassword": "your_release_pwd",
"password": "your_release_pwd",
"keystoreType": ""
}
}
}
3.编译打包apk命令
cordova build --debug
cordova build --release
4.报密码不匹配的错误
Failed to read key STORE from store "KEYSTORE": Keystore was tampered with, or password was incorrect
报密码不匹配等错误,多次调整也无效,可能是打包APK的缓存的问题
尝试清除下 ${cordova_root}/platforms/android/build
目录
5.Vue package.json中常用自定义命令
"scripts": {
......
"android": "cd ./platforms; cordova run android",
"ios": "cd ./platforms; cordova run ios",
"build:android": "./build_android.sh",
"install:apk": "adb install -r ./dist_package/*release.apk"
},
网友评论