Skip to content

Instantly share code, notes, and snippets.

@leommoore
Last active June 8, 2021 10:46
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save leommoore/b441473ce4fb1a8cee97 to your computer and use it in GitHub Desktop.
Save leommoore/b441473ce4fb1a8cee97 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.

    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
    
@globalepub
Copy link

"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
Copy link

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

@demirsoft
Copy link

ERROR (Jar signer CERT.RSA): JAR signature META-INF/CERT.SF indicates the APK is signed using APK Signature Scheme v2 but no such signature was found. Signature stripped?

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