Ionic 5's official documentation recommends using Android Studio to build the project. However, I can think of a few reasons to sidestep Android Studio in the build process:
- Android Studio is relatively resource-intensive
- A command-line method could be simpler and faster than opening up a full-blown Android development environment
- Using Android Studio just for the build process might break your workflow, if you've gotten comfortable with your existing development chain, say VScode and the CLI tools
Whatever your reasons are, Android apks could be built from your Ionic 5 project with a few extra commands. Before building, you can test if your app runs fine in the browser with this command:
If you don't have an Ionic 5 project ready, create a blank project with this command:
ionic start sample-ionic-angular-app blank --type=angular --capacitor
Refer to Ionic 5's first app docs for more details on how to get started with Ionic app development.
Step 1: Build the Ionic project
Step 2: Add support for the Android platform
ionic capacitor add android
Step 3: Sync changes from your Ionic project to the Android part
ionic capacitor sync
Step 4: Build for Android and generate apk
cd android && ./gradlew assembleDebug && cd ..
If the build completes successfully, you'll find your app's apk at
android/app/build/outputs/apk/debug/app-debug.apk. From now on, whenever you need to build for Android, you need to repeat only steps 3 and 4.
- How to build an Android APK file without using Android Studio in a Capacitor project?
- Cover image created from logos of Android and Ionic