Let's just say you want to debug your Flutter app on android device, you use a USB cable right?
Yes but using a USB cable has its downsides
- If your charging port is loose for some reason, then a slight move will disconnect your app ☹️
- On MacOS is displays a certain annoying "Please install SmartSwitch or some app" message
- Lack of flexibility
- Among other annoyances
So lets try debugging over wifi
Debugging over wifi
Requirements
- Your phone 📱
- Your machine 👨🏽💻
- A USB cable. 〜
- Your machine and phone should be connected to the same wifi.
Steps
Step 1
Connect your device to your machine using USB
Step 2
Open terminal and type the following
$ adb kill-server
$ adb tcpip 5555
This will kill current adb server and create another server which listens on all interfaces.
If it says something like this
* daemon not running; starting now at tcp:5037
* daemon started successfully
restarting in TCP mode port: 5555
Remove phone from mobile device and go to the next step
Step 3
Get you device's wifi IP address. To do this:
Go to
Settings > Connections > Click Wifi Name > View properties(Which has the IP)
Or
Settings > About Phone > Status > IP Address(Which has IP)
Your ip should be something like 192.168.100.X
Step 4
Inside your terminal type
adb connect YOUR_IP:5555
And if it says something like this:
connected to 192.168.100.X:5555
You are good to go
Safety Concerns
While this method offers convenience and flexibility, it might not be safe to do it on a public wifi or a wifi that you don't trust. After all someone might be listening in for open ports just to do something crazy, So be careful...
Top comments (1)
bravo, kudus to you