Android Debug on Real Device

I upload my ionic2 app on android device using “ionic run android --device”

I have some problem with http call but I don’t understant the problem and I need to enable debugging. Is it possible?

Thanks
Regards

Run ionic run android --device -l -c

l = live reload
c = console output

You can also use Google Chromes inspector: https://ionicframework.com/docs/resources/developer-tips/

4 Likes

Solved my problem… I need to add whitelist “cordova plugin add cordova-plugin-whitelist”

Tks

notice however that running with live reload flag makes cordova not availbale. For me that kind of defeats the purpose of testing on the device.

Still good tip, thank you!

@gilcatre Very true and it makes this whole thing useless. Ionic is kind of a nightmare to work with for native devices.

1 Like

I’ve tried all proposed solutions but it still doesn’t work

Depending on the version of Cordova you are using, you can open your app in Android Studio. This is supported in cordova-android >= 7.0

To start, simply run npm run ionic-app-scripts build, which produces your www dir.

Then all you do is open the platforms/android/ folder and Android Studio will do the rest. Sync gradle (tiny button in the upper left hand corner with a green refresh symbol), make sure you select the SDK platform version because the Cordova gradle file is not readable by Android Studio, and click the Debug/Play button. Make sure your device is plugged in and Android Studio will see it.

Once the app starts on device, you can open chrome://inspect and open a browser console for your device; in Android Studio, open the LogCat viewer.

LogCat will show you the native logging.
Chrome will show you the webview logging.

You can set breakpoints in native code in Android Studio, and breakpoints in JS code in the Chrome dev tools.

Using this setup makes LiveReload a complete waste of time, this setup is far superior.

It’s a true story, true!