DEV Community

loading...
Cover image for Build an Android app with Ionic, without Android Studio

Build an Android app with Ionic, without Android Studio

Rohan "HEXcube" Villoth
Cube³ the Fun!😊 I’m a UI/UX designer, former web developer and open source enthusiast.
・2 min read

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Step 2: Add support for the Android platform

ionic capacitor add android
Enter fullscreen mode Exit fullscreen mode

Step 3: Sync changes from your Ionic project to the Android part

ionic capacitor sync
Enter fullscreen mode Exit fullscreen mode

Step 4: Build for Android and generate apk

cd android && ./gradlew assembleDebug && cd ..
Enter fullscreen mode Exit fullscreen mode

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

Discussion (0)