Since Android 4.4 and Cordova 3.3+ we’ve got the opportunity to debug hybrid Apps remote. That’s pretty awesome because sometimes it is necessary to debug on the device.
First we have to check the requirements:
- We use Cordova 3.3+ (take a look at a workaround for previous versions here)
- We have a working Android 4.4 device in debug mode connected via USB
- Chrome in version 31+ is installed on the device and your PC
Ok let’s start. First we have to set the debug-flag in the Androidmanifest.xml. To do this simply add the following attribute to the <application> – node.
In the next step build and compile the app with grunt. But this step is optional. If you don’t use grunt or another task runner just skip this.
Ok let’s install the app on the device
cordova run android
Once the app is deployed and started we can start debugging. Start Chrome on your PC. Add a new Tab and navigate to the url:
Chrome will list all open Tabs (WebViews) on your connected device. One of these Tabs should be our App. Click inspect and debug your code like you alwasys do :-).