Andrew Fletcher published: 29 July 2022 2 minutes read
Run the NPX commands to update the app
npm run build && npx cap sync
Run app with live reload
ionic cap run {platform} -l --external
Replace {platform} with Android or iOS depending on your environment as follows
Android | android |
iOS | ios |
To open in Android
ionic cap run android -l --external
You'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 --copy
Or without specifying the platform:
cordova-res --skip-config --copy
How 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
Related articles
Andrew Fletcher
•
31 Oct 2023
Android icon not changing
If the Android app icon is not changing from the default icon (in my situation this was the Capacitor icon), here are some steps to troubleshoot and resolve the issue: Check the Icon FilesEnsure that you have provided the correct icon files in the appropriate directory. In a Capacitor project,...
Andrew Fletcher
•
11 Oct 2023
Launching app code in a simulator like Xcode or Android Studio
Loading the code in a platform - in this article, I'll be focusing on Android and iOS. Ionic app shell prompts for iOS and Android devices. Here's a breakdown of the commands:npm run buildThis command is used to build your web app. It's typically associated with web development frameworks...
Andrew Fletcher
•
29 Sep 2023
Setting up an ionic app
Recently a client handed me code that runs an app through iOS and Android. No details about whether native or otherwise. Once I had the opportunity to crawl through the code, definitely not native. Typescript, Angular, Cordova... etc.Glancing at the modification dates, the last...