Debugging your code on a physical device, remains the best way to really feel your app and ensure that you understand the way the app will work on the devices of your users.
But it can also be risky having your phone plugged constantly to your computer's USB port. Some computer USB ports do not really control current flow properly and power surges might damage your phone's charging port. Plus, what if your phone cord is short? or loose and doesn't allow much freedom?
So, you can use wireless debugging and here is how to wirelessly build, run and debug your apps on your physical device. First of all install ADB (Android Debug Bridge). ADB contains a set of tools to let you debug your app on your device.
INSTALL ADB ON MAC
To install ADB on mac, install with Home brew.
To install Homebrew, open a terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
After, run the following to install ADB:
brew install android-platform-tools --cask
These will take a while. So be patient and have a good network connection.
INSTALL ADB ON WINDOWS
Use this link to download Android SDK platform tools for windows.
Extract the zip file into a folder that is easily accessible. Something like C:\platform-tools
Now open that folder, and then Shift + right click to open command prompt right in that folder. Or just open command prompt and cd into the platform-tools folder.
After setting up ADB on your computer. Connect your phone to it by USB and also ensure your phone and computer are on the same network (LAN). Or you could just connect your computer to your phone's network or vice versa or connect both to same router.
Go to your phone's settings, go to about phone and click to view details of your phone. You should find the IP address there. Note it.
Come back to the terminal. If you are on windows, ensure you are in the ADB directory. If you installed with homebrew on mac , just run the script to start ADB daemon:
adb devices
You should see a list of devices and yours should be there.
Now run:
adb tcpip 5555
This restarts the the TCP
Go ahead and run:
adb connect <your android phone IP address here>
That is it! If its successful, you will see a success message on the terminal and you can go ahead to disconnect your phone. You will notice that the device will still be listed on the flutter's list of valid devices for debugging.
For Wireless Debugging With iPhone
Ensure you're running Mac OS 10.12.0 and above
Ensure you are running iOS 11 and above
Ensure you are running Xcode 9
Connect your Mac and iphone to same network
Open Xcode and go to window tab. On the drop-down menu, select devices and emulators
Select devices tab and select your devices from connected section.
Choose connect via network
You are good to go!
Enjoy!
Top comments (0)