IONIC Capacitor build Android Debug APK

Table of Content

IONIC Capacitor build Android Debug APK

Install Capacitor

npm install @capacitor/core @capacitor/cli
npx cap init

Add Android platform to Capacitor project

ionic build
npm install @capacitor/android
ionic cap add android

Build Android Debug APK with IONIC Capacitor

ionic cap copy
ionic cap sync

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

image

Build Production APK

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).

References

Leave a Reply

Your email address will not be published. Required fields are marked *