Permanent network debugging on android

I have a development platform for Android Things (Pico i.MX7D SOM) and don’t have a lot of time play with it. Sometimes I do, but it is here and there on average 1 hour a week. Most of the time it sits by the window, tracks the temperature and waits for a little update. Since it’s not on my desk debugging via cable is a pain. I really appreciate the possibility to debug over my wifi network.

However, even though debugging over the network is possible, it requires you to connect the cable after each reboot and restart adb in tcpip mode with this command:

$ adb tcpip 5555

Then you can connect to the device over the network and continue your development. You connect from your computer via:

$ adb connect

where is the IP of your android device.

Having to connect the cable after each reboot is annoying. Especially if you have unstable electricity (or a loose cable like me đŸ™‚ ) which results in occasional reboots. The good news is that there is a way to say to android to start adb in tcpip mode by default after each reboot:

# setprop persist.adb.tcp.port 5555

Notice (#) that you need to run this as the root if you want the setting to persist. This is what other resources often don’t mention explicitly, but su root before doing the setprop will do the job. Interestingly enough the command passes with su 0 (as suggested by other resources) without any errors (or any other message), but does nothing.

You might be horrified about the potential security issue. Pretty much anyone on the same network will have a possibility to run/install/update the apps on the device. It is a relevant point (if you do it on the phone), so make sure you do this only for devices that you are sure cannot be misused (in my case the device pretty much shows the temperature and time only).

Leave a Reply

Your email address will not be published. Required fields are marked *