Skip to content

Build Android App

Before we start the build App process, please make sure you have the following settings ready:

Note

It is highly recommended that you build Android and iOS App in seperate project folders.

Preparing a release Android APP bundle

The Android App Bundle is Android's new, official publishing format. Follow these steps to prepare a release APP Bundle for the Google Play Store.

Steps

  1. Open your terminal and cd to the project root.

    cd hamv_mobile
    
  2. Generate a release keystore.

    keytool -genkey -v -keystore <keystoreName>.keystore -alias <keystoreAlias> -keyalg RSA -keysize 2048 -validity <keystoreValidityTime> 
    

    Note

    keystoreName can be any words. e.g., release

    keystoreAlias is similar to keystoreName

    keystoreValidityTime is validity number of days. e.g., 365

  3. (Optional) Generate a key hash for Facebook Login.

    keytool -exportcert -alias <keystoreAlias> -keystore <keystoreName>.keystore | openssl sha1 -binary | openssl base64
    
  4. (Optional) Put your release key hash to Facebook developer:

    • Go to Facebook for Developers website
    • Select your app
    • Go to the page Settings/Basic https://developers.facebook.com/apps/<your APP Id>/settings/
    • Find the block "Android"
    • Put the key hash that you just generated into the field "Key Hashes"
    • Click "Save Changes"
  5. Prepare a production release config.

    • Copy and paste your release.keystore file to <project_root>/keystores folder.
    • Go back to <project_root> folder and open build.json.
    • Add the release information block to android scope. Edit storePassword, alias and password values.

    Here is an example of a build configuration file:

    {
        "android": {
            "debug": {
                "keystore": "./keystores/debug.keystore",
                "storePassword": "android",
                "alias": "androiddebugkey",
                "password" : "android",
                "keystoreType": ""
            },
            "release": {
                "keystore": "./keystores/release.keystore",
                "storePassword": "<release_keystore_password>",
                "alias": "<keystoreAlias>",
                "password" : "<release_password>",
                "keystoreType": ""
            }
        }
    }
    
  6. Build Docker image.

    docker-compose build
    
  7. Start a Docker container based on the built image.

    docker-compose run app sh
    
  8. The default build setting is to create .aab file. If your need to build .apk file for testing, please modify hamv_mobile_android.sh file under project root > customer folder. Remove the # from npx ionic cordova build android --prod and change the next line to #npx ionic cordova build android --prod --release as below example.

  9. Execute the following commands to install build environment dependencies under /work $

    ./customer/hamv_mobile_android.sh
    
  10. You should be able to see the “BUILD SUCCESSFUL” message.

    Note

    If the build failed, please remove the build materials by using this command in Docker container (under /work $) and repeat step 8 again.

    rm -rf node_modules/ plugins/ platforms/ .angular/
    

  11. After building process is done, you can find your android-release.aab under <project_root>/platforms/android/app/build/outputs/bundle/release folder. Or android-release.apk under <project_root>/platforms/android/app/build/outputs/apk/debug > apk folder.

Now you have your final release binary and you can release this to Google Play Store. See next chapter to publish your app on Google Play Store.

Have more questions? Submit a request


Last update: July 7, 2023