Build Android App¶
Before we start the build App process, please make sure you have the following settings ready:
- Build environment setup (Node, Ionic, Docker Desktop)
- App info setup
- App icon and splash
- (Optional) Language setting
- (Optional) Firebase GoogleService-info.json file for Push notification and Google login setting
- (Optional) Facebook login setting
- (Optional) Google account login setting
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¶
-
Open your terminal and cd to the project root.
cd hamv_mobile
-
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
-
(Optional) Generate a key hash for Facebook Login.
keytool -exportcert -alias <keystoreAlias> -keystore <keystoreName>.keystore | openssl sha1 -binary | openssl base64
-
(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"
-
Prepare a production release config.
- Copy and paste your
release.keystore
file to<project_root>/keystores
folder. - If you have not applied
env.sh
in previous chapter, please create a json file calledbuild.json
under project root. Add therelease
information block toandroid
scope. EditstorePassword
,alias
andpassword
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": "" } } }
- Copy and paste your
-
Build Docker image.
docker-compose build
-
Start a Docker container based on the built image.
docker-compose run app sh
-
Run build by using either method (a) or method (b)
(a) Use
env.sh
for project configurationIf you have applied your app settings in
env.sh
file, please execute the following commands to install build environment dependencies under/work $
:./customer/hamv_mobile_android.sh
(b) Manually set project configuration
If you did not apply the
env.sh
file but modified app configurations inpackage.json
,config.xml
, andapp.config.ts
, please run build by the following steps:(1) Run the following commands one by one under
/work $
.npm i app-engine-3.0.0.tgz
npm i
ionic cordova resources android --icon
ionic cordova platform add android@13.0.0
ionic cordova prepare android
(2) Build the debug/release version by the following commands:
Build debug version (apk):
Build release version (aab):ionic cordova build android --device --prod --debug
Build release version (apk):ionic cordova build android --device --prod --release
cordova build android --prod --release "--" --packageType=apk --verbose
-
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/
-
After building process is done, you can find your
android-release.aab
under<project_root>/platforms/android/app/build/outputs/bundle/release
folder. Orandroid-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