Is there a way to deploy/debug a Cordova Android Ionic app through WiFi?

Viewed 3024

This is a twin of this question (originally for iOS).

I would like to deploy and debug my Ionic app to an Android device connected via WiFi and not via USB with my PC, that is a device that I can reach just with WiFi.

Is this possible?

2 Answers

Yes, of course there is, provided that:

  • you have Chrome installed
  • you can plug-in your device via USB just ONCE.

If you can, in Windows you do like this

  1. install ADB by executing this as administrator saying yes (Y) to everything
  2. add ADB path to env variable (usually ADB is installed in the root so you do PATH=%PATH%C:\adb;)
  3. install a bash emulator
  4. USB plug-in the phone
  5. open the bash emulator and execute in order
  6. ID=$(adb devices | awk -F'device' '{if (match($0, /device$/)) print $1}');
  7. IP=$(adb shell ifconfig wlan0 | awk '{if (sub(/inet addr:/,"")) print $1 }');
  8. adb tcpip 5555;
  9. adb connect $IP:5555

now you can deploy the app just using the regular ionic cordova run android --device: Ionic will deploy the app on the last device configured on points 6-9.

For the same reason you can debug on Chrome simply by navigating chrome://inspect, and click on the device with the IP equal to that of point 7.

I have found most of these information here. Thanks Remy Sharp

Try to connect the device and the pc on the same network. Then run ionic run android —device -lc I don’t remember if you have to plug your device at least once for the build and then you can unplug and debug with WiFi maybe it’s not necessary.

Related