Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lfreneda/abe72891404c9d1a1ce8 to your computer and use it in GitHub Desktop.
Save lfreneda/abe72891404c9d1a1ce8 to your computer and use it in GitHub Desktop.
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.

```Bash
keytool -genkey -v -keystore myapp-release-key.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000
```
  1. 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
}
```
  1. Go to the directry
cd ./platforms/android/build/outputs/apk
  1. 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
    
  2. 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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment