Building and publishing an app for Android

Building and publishing an Android app is a little more straightforward than iOS because you just interface with the command line to build the .apk file and upload it to Google Play's Developer Console.

The Ionic Framework documentation also has a great instruction page for this, which is http://ionicframework.com/docs/guide/publishing.html.

Getting ready

The requirement is to have your Google Developer account ready and to log in to https://play.google.com/apps/publish.

Your local environment should also have the right SDK as well as keytool, jarsigner, and zipalign command line for that specific version.

How to do it…

Here are the instructions:

  1. Go to your app folder and build for Android with the following command:
    $ ionic package build --release android
    
  2. You will see the android-release-unsigned.apk in the /platforms/android/build/outputs/apk folder. Go to that folder in the terminal:
    How to do it…
  3. If this is the first time you created this app, you must have a keystore file. This file is used to identify your app for publishing. If you lose it, you cannot update your app later on. To create a keystore, type the following command line and ensure that it's the same keytool version of the SDK:
    $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
    
  4. Once you fill out the information in the command line, make a copy of this file somewhere safe because you will need it later.
  5. The next step is to use that file to sign your app so that it will create a new .apk that Google Play allows users to install:
    $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
    
  6. To prepare for the final .apk before upload, you must package it using zipalign, as follows:
    $ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
    

You need to ensure that zipalign is in PATH or you have to specify the absolute path. The app name could be anything you like or you can use the same name as created in this chapter:

  1. Log in to Google Developer Console and click on Add new application, as shown:
    How to do it…
  2. Fill out content rating and other information as possible for your app using the left menu:
    How to do it…
  3. Now you are ready to upload your .apk file. First is to do a Beta:
    How to do it…
  4. Once you are done with Beta testing, you can follow Developer Console instructions to push the app to production.

Note

If you run into any problem while publishing the app, it's helpful to look at the "Why can't I publish?" link in the dashboard's top right corner. Google will guide you on specific steps that must be completed or fixed.

How it works…

This section does not cover other Android marketplaces, such as Amazon app store, because each of them has different processes. However, the common idea is that you need to completely build the unsigned version of the .apk, sign it using an existing or new keystore file, and, finally, zipa lign to prepare it for upload.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.69.106