By default, APK generated by Cordova is a debug APK. But we need a release apk and moreover we need to sign it in order to make it be able to submit it somewhere or share with somebody.
Delete or comment anywhere there is android:debuggable="xyz"
cd to project root and run:
You will be asked various questions. Just answer them correctly, set two passwords, then you are good. A .keystore file will be created.
Create a build.json on project root:
The relase apk will be generated in ./platform/android/build/outputs/apk as android-release.apk
Ref:
https://stackoverflow.com/questions/26449512/how-to-create-signed-apk-file-using-cordova-command-line-interface
https://stackoverflow.com/questions/30106468/specify-signing-config-for-gradle-and-cordova-5
Preparation
Edit platforms/android/AndroidManifest.xmlDelete or comment anywhere there is android:debuggable="xyz"
<application <!-- android:debuggable="false" --> android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
cd to project root and run:
keytool -genkey -v -keystore example-mobileapps.keystore -alias example-mobileapps -keyalg RSA -keysize 2048 -validity 10000
You will be asked various questions. Just answer them correctly, set two passwords, then you are good. A .keystore file will be created.
Create a build.json on project root:
{
"android": {
"release": {
"keystore": "example-mobileapps.keystore",
"storePassword": "pass123",
"alias": "example-mobileapps",
"password" : "pass123",
"keystoreType": ""
}
}
}
How to build signed release APK with Cordova CLI
Now that we have everything setup, just run:cordova build android --release
The relase apk will be generated in ./platform/android/build/outputs/apk as android-release.apk
Ref:
https://stackoverflow.com/questions/26449512/how-to-create-signed-apk-file-using-cordova-command-line-interface
https://stackoverflow.com/questions/30106468/specify-signing-config-for-gradle-and-cordova-5
No comments:
Post a Comment