How To Connect An Android Device With A USB Cable or WiFi or A Bonus Method
Connect Your Device To Computer For Debugging your App
INTRODUCTION
While Developing for Android I Have Encountered with one Problem That is to test our app we need to Connect To a Real Android Device And For That We Have Two Options And That is Android Emulator Or A Real Android Device.
Why Don't I Use A Android Emulator
Android Emulator Requires A Heavy Amount Of Hardware Requirements which becomes a hindrance in the life of android development So, If You Have a PC with A Great Amount Of Hardware like an SSD, A Processor With A Clock Speed Of More Than A 3.0gHz and Other. That's Why I Avoid To Keep My PC Free From Covering This Much Resources
How To Use A Real Android Device
To Use A Real Android Device We Can Use 3 Methods :-
Connect Via USB Cable
To Connect Via USB Cable You Have To Follow Some Small Method That is:-
- Go To Settings
- Visit To The About Device
- Open Software Information
- Click On Build Number For About 8-9 Times
- A Small Box shows
Now You're A Developer
- Search For Developer Options
- Enter In it.
- Connect The Phone With A USB Cable
- Enable USB Debugging. Check Out This For The Above Method
Connect Via Wireless Debugging
- Have You Downloaded Android Studio If Not Download Download Android Studio
- Connect The Laptop And The Phone With same WiFi.
- Open Android Studio And Land On This Screen.
- Click On The Wireless Debugging which is Found in the Developer Options.
- Now Connect Both Devices With A Same WiFi Network📶 .
- Now Open The Developer Options On Your Device On Which You Would Test Your App.
- Switch On The Wireless Debugging And Click On The Wireless Debugging Option.
- Now, You Have Two Options By Pair Device with QR Code And Pair Device with Pairing Code.
- If You Want To Scan The QR Code, Then Click On The Pair Device With QR Code On Android And On The Screen You Will Be Shown With The QR Code. Then Scan The QR Code.
- If You Want To Pair Device With Pairing Code. Click On The Option Then You Will Be Displayed With A Code And On Computer Click On The Pairing Code.
- Click On The Pair Option And Now Your Phone is Paired With Computer For Wireless Debugging.
Now A Bonus Method And The Easiest Method
- Open The Path In An terminal/powershell
cd C:\Users\[USER_NAME]\AppData\Local\Android\Sdk\platform-tools
Connect Your Device With USB
type the below in the terminal/powershell
adb tcpip 5555
Find Your Device's IP Address From Your Device Settings
After This Then Type this in the terminal/powershell
adb connect [IP_ADDRESS]:5555 *remove brackets
- And It Will Result
- Which Shows Your Device is Successfully Running On The Wireless Debugging
This Method Is Working For All Types If You Are using On Wifi or Mobile HotSpot For Future Better Using Of The Feature Add The Path To The Environment Variables
Hope You Liked The Blog And If You Face Any Issue Direct Message Me On My Twitter Handle or Comment .