Andrew Fletcher published: 29 July 2022 2 minutes read
Run the NPX commands to update the app
npm run build && npx cap syncRun app with live reload
ionic cap run {platform} -l --externalReplace {platform} with Android or iOS depending on your environment as follows
| Android | android |
| iOS | ios |
To open in Android
ionic cap run android -l --externalYou'll be prompted to select a emulator (depending what you have loaded)
? Which device would you like to target?
Pixel 3 API 31 (emulator) (Pixel_3_API_31)
Pixel 5 API 27 (emulator) (Pixel_5_API_27)
Pixel 5 API 30 (emulator) (Pixel_5_API_30)
Pixel 5 API 31 (emulator) (Pixel_5_API_31)
❯ Pixel 5 API 33 (emulator) (Pixel_5_API_33)
Generate a release APK without opening Android Studio
ionic capacitor copy android --prod && cd android && ./gradlew assembleRelease && cd ..Generate a debug APK without opening Android Studio
ionic capacitor copy android && cd android && ./gradlew assembleDebug && cd ..Generate icons & splash screen in a top-level resources folder within your project, like so:
resources/
├── icon.png
└── splash.png
Run the following command:
cordova-res ios --skip-config --copy
cordova-res android --skip-config --copyOr without specifying the platform:
cordova-res --skip-config --copyHow to build and run APK directly on the device from CLI
ionic capacitor copy android && cd android && ./gradlew assembleDebug && ./gradlew installDebug && cd ..Open app using Android Studio or Xcode
npx cap open {platform}As per notes earlier, replace {platform} with the respective environment you are targeting. So to open in Android Studio
npx cap open android