Generate android bundle/apk for ionic mobile app

  1. open terminal
  2. go to project directory
  3. run – npm update
    1. to make sure all components imported added first
  4. run – ionic build
    1. this will build files in web directory (normally www)
  5. run – ionic cap add android
    1. android directory will be created in ionic project
  6. run – “ionic cap copy android” to copy to android native project. this to run everytime you run “ionic build” to copy latest files to native android project
  7. run – ionic cap open android
    1. will open android studio
    2. this will take quite some time for android to build
  8. in android studio. Go to Build > Build Bundle(s)/APK
  9. APK willl be generated. Click on Locate to show the apk file

Optional

  1. optional – run – ionic cap sync – if you download any plugin to be used in the app

Other notes

  1. I faced issue the “Build Bundle(s)/APK(s)” and “Generate signed Bundle/APK” did not appear in the menu.
  2. To settle this issue, go to Android Studio > Preferences > Appearance and Behavior > System Settings > Android SDK. Choose SDK Tools tab. Tick on SDK Build-Tools and Android SDK Command-line Tools. Then click Apply. Agree to the terms and proceed.

Reference:

  1. https://ionicframework.com/docs/angular/your-first-app/6-deploying-mobile
  2. https://ionicframework.com/docs/developing/android

Leave a Reply

Your email address will not be published. Required fields are marked *