Releasing Ionic app on Android

Where are there accurate, recent instructions for publishing my Ionic 2 app on the Google Play store. I don’t see anything in the docs or immediately catering to this on the forums, but I probably missed it.

D

cordova plugin rm cordova-plugin-console

cordova build --release android

keytool -genkey -v -keystore my-keystore-file.keystore -alias EMAIL/PACKAGE_NAME/UNIQUE_ID -keyalg RSA -keysize 2048 -validity 10000

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore PATH_TO/my-keystore-file.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk EMAIL/PACKAGE_NAME/UNIQUE_ID

~/Library/Android/sdk/build-tools/23.0.0/zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk signed_releases/APP_NAME_$(date +%F).apk

You only need to generate your keystore the first time (third command), keep that file on a safe place!
Customize the paths I use to your own ones and you should be able to generate your signed apk.

6 Likes

you can also use this one-liner if you already have a key in your keystore.jks:
ionic build android --release -- --keystore="../android.keystore" --storePassword=android --alias=mykey --password=myKeyPassword

see cordova help build and/or cordova docs for detailed information

4 Likes

this is the best guide

http://ionicframework.com/docs/guide/publishing.html

Be really carefull with your keystore, if you lose it, you won’t be able to update the app

1 Like

It looks like Ionic1 and not Ionic2

There is no difference for this task.

thanks very much that very help for me

this one liner worked for me in the past but i came after two months (now may 2017) back to my project and its generating only unsigned apk any known reason?

Sorry man, no idea. I moved all my builds (android and iOS) to the ionic cloud.
Android works for development and production, iOS only development …

really interesting so maybe i should also consider ionic cloud…
interesting so you helped me

For development builds I use:

- export IONIC_PACKAGE_BUILD_RELEASE="false"
- export IONIC_PACKAGE_BUILD_PROFILE="xxxx"
- ./sh/ionic-login.sh
- npm run build
- ./sh/ionic-package.sh android
- ./sh/ionic-package.sh ios

IONIC_PACKAGE_BUILD_PROFILE is the name of your profile in the ionic cloud.

ionic-login.sh: https://github.com/marcoturi/ionic-boilerplate/blob/master/sh/ionic-login.sh

and ionic-package.sh I adapted like this:

...
  if [ -z "$1" ]; then
    fail "ionic-package: specify either 'ios' or 'android' as parameter of the script"
  fi

  # Command arguments
  args="$1"
...

HTH :slight_smile:

A post was split to a new topic: Keystore file does not exist