This guide covers how to deploy Ionic apps to Android simulators and devices using Capacitor or Cordova.
To deploy apps to an Android device and debug them, developer mode must be enabled and allow for USB debugging turned on. Check out these instructions to do this on a device.
Before apps can be deployed to Android simulators and devices, the native project must be configured.
Generate the native project, if it does not already exist.
For Capacitor, run the following:shell
ionic capacitor add android
For Cordova, run the following:shell
ionic cordova prepare android
Set the Package ID.
For Capacitor, open the
capacitor.config.jsonfile and modify the
For Cordova, open the
config.xmlfile and modify the
idattribute of the root element,
<widget>. See the Cordova documentation for more information.
Running with Capacitor
Capacitor uses Android Studio to build and run apps to simulators and devices.
Develop the Ionic app and sync it to the native project.
With each meaningful change, Ionic apps must be built into web assets before the change can appear on Android simulators and devices. The web assets then must be copied into the native project. Luckily, this process is made easy with a single Ionic CLI command.shell
ionic capacitor copy android
In Android Studio, select a target simulator or device and click the run button.
Running with Cordova
The Ionic CLI can build, copy, and deploy Ionic apps to Android simulators and devices with a single command. It can also spin up a development server, like the one used in
ionic serve, to provide live-reload functionality.
Run the following to start a long-running CLI process that boots up a live-reload server:
ionic cordova run android -l
Now, when changes are made to the app's source files, web assets are rebuilt and the changes are reflected on the simulator or device without having to deploy again.
Using Chrome DevTools to debug
Chrome has devtools support for Android simulators and devices. Go to
chrome://inspect in Chrome while the simulator is running or a device is connected to the computer and select the app that needs to be debugged.
Viewing Native Logs
Native logs can be found in Android Studio in the Console.