Hello folks, I am back with yet another post in the Solving Technical Series. Android developers use the ADB interface to debug their apps, and polish it until they release it. In a world full of wires, when a developer wants to break free from wires and do debugging over wireless modem on his phone, he has only one option : do debugging over WiFi. This option works only if he is on a custom ROM based on CyanogenMod/LineageOS or has his original ROM rooted and using 3rd party apps.

Consider India. The release of Jio in the market has proven to be a boon to the users. So nowadays, Jio users do not want to connect their devices to WiFi. They’d rather connect these devices to the mobile hotspot.

In this scenario and other similar scenarios, things are slightly complex for Android Developers who want to use ADB over mobile hotspot. I searched through Stack Overflow and other relevant sites on how to do this. Out of the search results, one worked partially, others never worked. Here are the pages I am refering to [1] (partially worked) , [2] , [3]

The first one partially worked, sometimes but not everytime. I was scratching my head until I came upon this app

PREREQUISITES

  1. The above mentioned app
  2. ADB enabled on your phone
  3. A rooted phone (Important, without which there is no use of doing this)

I ran this app, then enabled the toggle, finally saw something like this below:

It is showing an IPv6 address, which cannot be used to connect to ADB if the Android is not Nougat or above. That is where I was doomed. My Redmi Note 3 was running a custom ROM over Marshmallow (using a Nougat theme via CMTE, in case you were wondering of that icon).

But having a small experience in MAC address spoofing, I knew some Linux commands. The first thing I did was to connect my phone via USB to the laptop. Then I connected it to the ADB shell (adb shell). Then I ran ifconfig. There I can see a list of Modems in my phone. What I am concerned with is dummy0 (as shown in the screenshot) and wlan0.

As you can see in the screenshot there is an IPv6 address for dummy0 and IPv4 and IPv6 addresses for wlan0. So I ran adb connect <IPv6 addr> of both the modems. Luck failed. But then I ran adb connect for the inet addr of wlan0, which is coincidentally an IPv4 address. When I did that, booom…. Connected to 192.168.43.1:5555

STEPS

One-time steps:

  1. Connect phone to PC via USB
  2. Connect your device to ADB
  3. Run adb shell ifconfig. Note the inet addr value of wlan0
  4. Disconnect the phone

Now remember the value of the inet addr . This is important. Now whenever you want to connect ADB over hotspot:

  1. Enable the toggle in the app
  2. Run adb connect <value of inet addr>. Then it must show connected to <inet addr>:5555.

Now you can do whatever you like.

CONCLUSION

Please share this article, and let this get maximum reach. Android developers connected in the wires want to break free from this one day. So please, help developers make the world a better place.

[1] : http://stackoverflow.com/questions/8861901/how-to-use-adb-over-mobile-ap-portable-wifi-hotspot [2] : http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp [3] : https://gist.github.com/liminal/8801401

UPDATE

Just to test my curiosity, I installed Android 7.1.2 on my device just to test this. Seems like connecting via an IPv6 address still didn’t work for me. Although connecting through this app and then following the steps above did the job for me.