Cordova 打包 Android release app 过程详解:
1.全局安装Cordova CLI:
npm install -g cordova
2.创建项目:
cordova create cordova-demo com.example.cordovaDemo cordovaDemo
3.添加平台:
cordova platform add android
4.构建apk:
cordova build android
5.建立符合链接 android-apk:
ln -s platforms/android/build/outputs/apk android-apk
6.查看android-debug-unsigned.apk:
ls android-apk
构建release版本:
7.Build :
cordova build --release
8.Sign:
keytool -genkey -v -keystore release-key.keystore -alias cordova-demo -keyalg RSA -keysize
2048 -validity 10000
9.对APK签名:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore release-key.keystore
android-apk/android-release-unsigned.apk cordova-demo
10.Align:
zipalign -v 4 android-apk/android-release-unsigned.apk android-apk/cordova-demo.apk
注:自动打包
cordova build android --release -- --keystore="release-key.keystore" --alias=cordova-demo --
storePassword=testing --password=testing2
文件内容如下:
{
"android": {
"release": {
"keystore": "release-key.keystore",
"alias": "cordova-demo",
"storePassword": "testing",
"password": "testing2"
}
}
}
.