Skip to content

Instantly share code, notes, and snippets.

@rknell
Last active November 7, 2023 08:23
Show Gist options
  • Save rknell/8857002 to your computer and use it in GitHub Desktop.
Save rknell/8857002 to your computer and use it in GitHub Desktop.
Build Android Release apk from Cordova /CLI
#!/bin/bash
#Thanks to this page: http://chris-allen-lane.com/2012/12/phonegap-compiling-a-release-apk-without-using-phonegap-build/
#USAGE!
# 1. Replace <AndroidKeyName> with the filename of the keyfile generated (see url)
# 2. Replace <ProjectName> with the project name in the generated file form cordova, see path/to/my/project/platforms/android/bin and look for an APK if you need help
# 3. Replace <AndroidKeyNameAlias> from the alias used when generating the key (see url again!)
# 4. Edit path/to/my/project/platforms/android/AndroidManifest.xml and change "debuggable=false" (search for it!)
# 5. Check path/to/my/project/Release/android for your sparkling new apk!
#
# This worked and was uploadable to the google play store.
cordova build android --release
ant release -f platforms/android/build.xml
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore <AndroidKeyName>.keystore platforms/android/bin/<ProjectName>-release-unsigned.apk <AndroidKeyNameAlias>
mkdir -p Release/android
zipalign -f 4 platforms/android/bin/<ProjectName>-release-unsigned.apk Release/android/<ProjectName>-release.apk
@danielpza
Copy link

i got the same error

@rknell
Copy link
Author

rknell commented Mar 13, 2019

@technomacx and @danielpa9708 im sure this is old (I didn't realise anybody had commented on this gist)

You might need to recreate the platform, ie cordova platform rm android && cordova platform add android etc

The build.xml should be created automatically but if you checked the project out of source control it may not have been committed the first time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment