- open terminal
- go to project directory
- run – npm update
- to make sure all components imported added first
- run – ionic build
- this will build files in web directory (normally www)
- run – ionic cap add android
- android directory will be created in ionic project
- 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
- run – ionic cap open android
- will open android studio
- this will take quite some time for android to build
- in android studio. Go to Build > Build Bundle(s)/APK
- APK willl be generated. Click on Locate to show the apk file
Optional
- optional – run – ionic cap sync – if you download any plugin to be used in the app
Other notes
- I faced issue the “Build Bundle(s)/APK(s)” and “Generate signed Bundle/APK” did not appear in the menu.
- 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: