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

Here is how to production build for Android:

cd android && 
./gradlew assembleRelease && 
cd app/build/outputs/apk/release &&
jarsigner -keystore YOUR_KEYSTORE_PATH -storepass YOUR_KEYSTORE_PASS app-release-unsigned.apk YOUR_KEYSTORE_ALIAS &&
zipalign 4 app-release-unsigned.apk app-release.apk

This will generate app-release.apk which should be good to go the play store (see android/app/build/outputs/apk/release folder).

Here is the jarsigner command manual.

13 Likes