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:
ionic serve
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
ionic build
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.
Credits & Sources
- How to build an Android APK file without using Android Studio in a Capacitor project?
- Cover image created from logos of Android and Ionic
Top comments (1)
Hi Rohan,
I'm implementing CI/CD pipeline with GitHub Actions. So for I have a debug.apk file with these commands. My goal is to sign the apk file and deploy to google play.
on my pipeline I have these commands and after that signing the app script and deploy to google script. Between these commands and signing the app should I add any script? Right now it is actually signing the app but on the deploy to google play part it is not finding the signed file. Any suggestions to this issue?