简体   繁体   中英

Building Cordova release apk

I am finding it extremely difficult to get my heard around signing my app under the new cordova 5.0 guideline

this is what i have done

(bongoapp)project root
 ->build.json
 ->phistoKey.keystore
 ->www

this is what i have inside my build.json file

{
 "android": {
     "release": {
         "keystore": "phistoKey.keystore",
         "storePassword": "",
         "alias": "phistoKey",
         "password" : "",
         "keystoreType": ""
     }
 }

}

when i try

cordova build --release

or

cordova build android --release

I get error stating

Keystore file does not exist: C:\wamp\www\towncrier\platforms\android\..\..\phistoKey.keystore

I will be glad if anyone can help cos I am on a deadline TODAY. thank you

The way I do it in new Cordova CLI (with gradle) is using the options that cordova give us for doing it without make our own script or doing it manually in different steps. In my case, I have created a file in platforms/android directory, with the name release-signing.properties . The content of this should be the configuration for signing your apk, something like:

key.store=/PATH/TO/YOUR/KEYSTORE
key.alias=your_alias
key.store.password=key_store_pass
key.alias.password=key_store_alias

With this file created, you just need to run the standard command, cordova build android --release , and it will generate new release APK in your output directory ( platforms/android/outputs/apk/yourapp-release.apk )

In cordova 6.2.0

cd cordova/ #change to root cordova folder
platforms/android/cordova/clean #clean if you want
cordova build android --release -- --keystore="/path/to/keystore" --storePassword=password --alias=alias_name #password will be prompted if you have any

I do the following in a shell script to build and sign an APK. This assumes that the app is named "bongoapp" and that your Cordova project and keystore file (phistoKey.keystore) are located in the same folder as the shell script.

# Run this script in the bongoapp folder to build and sign a release APK.
# Hint: the password is "bongoapp"

# Build the release APK
echo "Building Android release APK"
cordova build android --release

# Sign the APK
echo "Signing Android release APK"
jarsigner -verbose -certs -sigalg SHA1withRSA -digestalg SHA1 -keystore phistoKey.keystore platforms/android/ant-build/MainActivity-release-unsigned.apk bongoapp_alias
jarsigner -verbose -certs -verify platforms/android/ant-build/MainActivity-release-unsigned.apk
zipalign -v 4 platforms/android/ant-build/MainActivity-release-unsigned.apk platforms/android/ant-build/bongoapp.apk

echo "Done, output file is located here -> platforms/android/ant-build/bongoapp.apk"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM