npx cap run android does all of this in one step (cap run), but it can restart the adb server, so on a machine shared with other emulators build and install by hand:
npm run build && npx cap sync android
(cd android && JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 ./gradlew assembleDebug)
adb -s emulator-5558 install -r android/app/build/outputs/apk/debug/app-debug.apk
adb -s emulator-5558 shell am start -n com.example.booknest/.MainActivity
adb -s emulator-5558 logcat -v tag -s Capacitor -e "Loading app|App started" -m 2Output
...
[info] Sync finished in 0.519s
...
BUILD SUCCESSFUL in 18s
611 actionable tasks: 27 executed, 584 up-to-date
Performing Streamed Install
Success
Starting: Intent { cmp=com.example.booknest/.MainActivity }
--------- beginning of main
D/Capacitor: Loading app at https://localhost
D/Capacitor: App startedFor quicker Framework7 572,986 iterations use live reload against the dev server (Live Reload). To debug, open chrome://inspect in desktop Chrome 1 : the app appears as https://localhost/ with its console, DOM and network (Remote Debugging Android).