How to build an Android APK file without using Android Studio in a Capacitor project?

I was having this issue and the way I worked out to do this:

You need to add android first:

ionic capacitor add android 
ionic capacitor copy android && cd android && ./gradlew assembleDebug && cd ..

Then your apk will be at:

android/app/build/outputs/apk/debug/app-debug.apk

If you want to run on device directly from command line:

ionic capacitor copy android && cd android && ./gradlew assembleDebug && ./gradlew installDebug && cd ..

Note: It doesn’t work without entering the android directory

I hope that helps!

29 Likes