Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ionic Publish Android App

#Ionic Publish Android App

This is the process to publish an ionic android app.

  1. Make sure you set/increment the version number in config.xml ie 0.0.3.

  2. Make sure the android platform has been added

    ionic platform add android
    
  3. Remove the debug console

    cordova plugin rm org.apache.cordova.console   #Old Name
    cordova plugin rm cordova-plugin-console       #New Name
    
  4. Create the signing key (This need to be done only once) You need to create a signing key for your myapp. Note: Make sure you keep the keystore file safe as you will need it to release updates.

    keytool -genkey -v -keystore myapp-release-key.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000
    
  5. Create the release This will create the release. Remember to increment the version number in the config.xml.

    ionic build --release android
    

    This will generate a release build based on the settings in your config.xml. Your Ionic app will have preset default values in this file, but if you need to customize how your app is built, you can edit this file to fit your preferences. Check out the config.xml file documentation for more information.

    One issue that can occur is that the build process can generate an errors because the app is not translated into other languages. The error will be something like:

    :lintVitalArmv7Release
    /Users/xxx/Documents/xxx/xxx/platforms/android/res/values/arrays.xml:3: Error: "country_codes" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "eu" (Basque), "fi" (Finnish), "fr" (French), "he" (Hebrew), "hi" (Hindi), "hu" (Hungarian), "id" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ko" (Korean), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sv" (Swedish), "tr" (Turkish), "zh-rCN" (Chinese: China), "zh-rTW" (Chinese: Taiwan, Province of China) [MissingTranslation]
      <string-array name="country_codes">
    

    In this case the solution is to put the following lines in the platforms/android/build.gradle file at line 243.

    lintOptions {
        abortOnError false
    }
    
  6. Go to the directory

    cd ./platforms/android/build/outputs/apk
    
  7. Sign the unsigned APK To sign the file you will need to use the jarsigner tool.

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myapp-release-key.keystore android-release-unsigned.apk myapp
    
  8. Zip align the resulting APK The zipalign tool is in the android-sdk/build-tools/{version}/ folder.

    ~/android-sdk/build-tools/22.0.0/zipalign -v 4 android-release-unsigned.apk myapp.apk
    
@ravishtiwari

This comment has been minimized.

Copy link

ravishtiwari commented May 3, 2016

following:

cordova plugin rm cordova-plugin-console // OR cordova plugin rm org.apache.cordova.console`\

does not work, try running

ionic build --release android

You'll see this:

Fetching plugin "cordova-plugin-console@~1.0.1" via npm
Installing "cordova-plugin-console" for android
Installing "cordova-plugin-console" for ios
@yarnball

This comment has been minimized.

Copy link

yarnball commented May 12, 2016

My build tools were located at; /usr/local/Cellar/android-sdk/24.4.1/build-tools/23.0.2/zipalign

I'm on OSX. Not sure what that's happening

@vilellaj

This comment has been minimized.

Copy link

vilellaj commented Dec 13, 2016

Great guide!

Just an observation:
If you face a message like:

You cannot run iOS unless you are on Mac OSX

Try using

ionic build android --release

instead of

ionic build --release android

@Moix1

This comment has been minimized.

Copy link

Moix1 commented Dec 13, 2016

i'm facing error
please help me

Where i should write it ?

keytool -genkey -v -keystore myapp-release-key.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

@globalepub

This comment has been minimized.

Copy link

globalepub commented Dec 17, 2016

"C:\Program Files\Java\jdk1.8.0_111\bin\keytool" -genkey -v -keytool -genkey -v -keystore myapp-release-key.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

@perspolice

This comment has been minimized.

Copy link

perspolice commented Mar 23, 2017

hi thank you,
how can I update the version of zipalign and farsigner automatically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.