This article will show you how to connect your android physical device to your computer, and how to deal with the problems you may encounter.
Prerequisites:
You can follow this article’s prerequisites section.
Enable 3rd Party Applications On Your Phone.
You need to enable developer mode in your phone. This feature varies for different phones. In this article we will give you an example.
Go to Settings>Additional Settings> Developer Options
and enable USB debugging and Install via USB options.
Installing Your App To Your Device
Connect your phone to your computer with USB cable and make sure transfer files option is enabled.
After you’ve connected your phone with USB cable. You can check if it’s connected or not by typing command below.
adb devices
You should see your device attached.
Run your app in Android Studio.
Accept app to be installed on your phone.
Connect Your Device Over Wifi
Define the adb TCP/IP port to be used, for to do this type the command below on.
adb tcpip 5555
Now you can unplug your device from your computer. Next step is learning your IP address. Type command below.
ipconfig
Open your app and shake your phone.This will open developer options window and follow images below. Type your private IP in the section on the third image and add port 8081 to the end.
Next step is learning your phone’s IP address. To do that you can follow the steps in images below.
After you get your IP address of your phone; type the command down below in terminal to connect your phone and computer.
adb connect <YOUR_PHONE_IP>
In terminal you should see “connected to <YOUR_PHONE_IP>” message.
After all these steps you can reload your app by clicking Reload option in developer menu.
Beware that your phone’s IP will change over time. When that happens you should redo the last step.
Bugs And Errors You Might Encounter
-ADB server didn’t ACK-
To solve this problem open Task Manager and end task adb.exe .
Type commands below.
adb kill-server
adb start-server
adb connect <YOUR_PHONE_IP>
adb devices
After last command you should see your phone listed as an attached device.
Sometimes ADB server will expire you can solve this problem by typing commands above.
Thank you for reading. You can follow us to learn more about react & react native development.
Feel free to ask anything about this article if you get any errors. You can contact any of us on linkedin.
MTA Team:
Ali Gümüş Tosun— Semih Sevincli— Aslancan Yılmaz— Burak Arıcı
LinkedIn Accounts:
Ali Gümüş Tosun — Semih Sevinçli — Aslancan Yılmaz — Burak Arıcı