Friday, January 29, 2016

Deploying Android applications to a device without a USB cable (Hands-free development)

I just answered a question on stackoverflow that I think worth a blog. The asker is developing an Ionic app that uses a connected USB printer, and he was testing his app dong the following

1- Connect the device to his computer using USB
2- Deploy the app to the mobile
3- Disconnect the USB cable form the device
4- Connect the printer cable to the device
5- Test the app.

This sounded much to him and to me -as a lazy developer- but luckily I remembered hearing about adb over Wi-fi that allows deploying the apk file over Wifi network, and I wondered why would not this work with Ioinc, and it turns out it did work. Here is how the first time setup is done:

  1. Connect your android device to your computer using a USB cable
  2. From a command line run adb tcpip 1234 // or any port of your chosing
  3. disconnect your android USB cable
  4. run adb connect <your-phone-ip>:1234
  5. Connect your printer using the USB cable
After that, he can simply test his app by doing  ionic run android to deploy your app and enjoy a cable-switching free development experience. 

No comments:

Post a Comment