To deploy and debug apps on an Android device, you must follow these
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:
$ ionic capacitor add android
For Cordova, run the following:
$ ionic cordova prepare android
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.
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.
$ ionic capacitor copy android
In Android Studio, click the Run button and then select the target simulator or device.
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
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.
Once an app is running on an Android device or emulator, it can be debugged with Chrome DevTools.
Chrome has web developer tool 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
Inspect the app that needs to be debugged.
Make sure your application is running on the device or simulator, or it will not show up in the list.
If running with Android Studio, native logs can be found in Logcat.
If the Logcat window is hidden, you can enable it in View » Tool Windows » Logcat.
You can also access Logcat with ADB.
$ adb logcat