How to Wirelessly Connect Device to Android Studio
This is yet another everyday productivity for my fellow Android developers. Here I will show step by step on how you can wirelessly connect your device to Android Studio without using a cable.
What you should already know before reading further ? It’s nothing, you will require the basics of ADB and Android Studio. Along with the knowledge about the terminal or the command line. Though I have no Windows OS to check this. You might try this exact same thing wish bash, might work for you.
So all it comes down to is these things:
- Basic knowledge on ADB ( I will not be explaining what it is here )
- Familiar with Android Studio navigation
- Comfortable with the terminal and command line
- WiFi connection obviously
That is pretty much everything you will be needing to set everything up!
Installing & Configuring ADB
Well, if you are reading this you probably know why you are here. So the installation part is outta the question. Assuming you have android studio up and running you do not need any further installation step.
But what you need is making sure the ADB from android studio is used. Go ahead and type
adb in you terminal. If you don’t see something similar to the image below. We need to set up our path.
The next portion is the answer to: How do we setup the
$PATH variable in Ubuntu ?
Open up the file
~/.bashrc in your favorite editor. I will use nano here because I haven’t really learned how to use
Navigate to the bottom of the file and add this line:
The line above assumes that you have your
Android SDK located in your
/home/<user> directory. Everything that follows is the relative path from there. Which will be same for everyone.
Save the file now and exit the editor. After exiting type the command:
source ~/.bashrc in your terminal for refreshing that file for the terminal.
So that is it you have setup path in your Ubuntu. A bit easier in Ubuntu than in Windows IMO.
If you are interested in Android development, then you mustLearn why Android fragment onActivityCreated() is deprecated !
Finding the IP of your Android device
I hope you have your USB handy. Connect your device to the PC and if Android Studio detects it move forward with this.
In the terminal type
adb shell and press enter you will be inside the device. Once you are in the device type
ifconfig which will give you the screen below. The IP of your device is generally
192.X.X.X note it and then exit the terminal.
Up to this point you are dependent on the USB cable. Which is going to end soon.
Connect to the device
Plug your device in and type the command
adb tcpip 5555 and then the adb daemon in device will restart and listen for port 5555. Feel free to change the port you wish.
You can disconnect your device now.
The daemon will listen to the port 5555 for adb connections until your restart / shutdown your mobile phone. Meaning, you will have to restart the process if you restart / shutdown your phone.
The final step is to connect via WiFi by entering the command below:
adb connect 192.X.X.X:5555
In the command above the
PORT are the ones you chose during the article.
Your Android smartphone should now be connected to the computer. Also it’s worth noting that you have to do
adb connect command every time you exit Android Studio or the
adb server gets killed.
That’s it folks you do not need any plugins to achieve this. You have successfully learned how to wirelessly connect Android device to Android Studio
Naveen Niraula SaysBored from COVID19? Read my experiences here, COVID19 WFM: The Ultimate Lessons.