Android Tip: adb reverse
I work from all over the place: Home, on public transit, the office, coffee shops, etc.
A big challenge to developing android apps in an environment where my laptop and phone are on different networks (wifi vs. LTE, or laptop tethered through phone) is the inability for my phone to see the API server that is often running locally on my laptop. Here is a simple tip to allow your phone to hit the backend over ADB and a usb cable.
adb reverse
$ adb reverse tcp:3000 tcp:3000
That is it. Now when your phone tries to access http://localhost:3000/
your request will be routed to localhost:3000 of your laptop. Just recompile your app to use localhost:3000
as the API endpoint.
Additionally you can replace the ports with anything. If you want you could use
$ adb reverse tcp:80 tcp:3000
To redirect your phone’s port 80 to your computer’s port 3000. Adjust it to your needs and enjoy debugging from your phone while on the go!
1 Comment