In this post we will see how to use Android mobile as an emulator for android studio.
android studio built in emulator is bit heavy and if your PC configuration is low then you have noticed that launching emulator is time consuming task. it may take more that 5 minutes to start completely. Emulator consumes lots of memory and this makes whole system slow.
so lets get started.
We can connect mobile phone to PC via USB cable or Wifi.
Before this we have to enable usb debugging in mobile.
follow these steps to enable developer option if you have not enabled it.
1. goto your phone setting then about phone
2.look for option build number/version
3.tap on this for 7 times
then it will be enabled
4.go back to setting you will see new Menu option developer option.
5.click on this enable it now
6.scroll down you will see usb debugging.
enable this
7.some device may block you to install app via usb.
so there is one more option.
allow install via usb
enable this too
8.connect your mobile to pc using USB cable.
9.open android studio
open project you are working on
click run
here your mobile phone is shown connected via usb.
10.if still its not showing then you need to install/update adb driver on your pc.
search on google ‘adb universal drivers’
download it install it
now your phone should get connected
11.you may get permission prompt to accept debugging from your pc/laptop.
just accept it.
12.your phone is now visible under adb connected devices and ready to use as emulator.
On some mobile phone sometimes you may get problem app crash like on miui devices redmi note 3.
for this disable instant run feature of android studio.
1.Android Studio
click file menu then goto setting
2.on left select Build, Execution, Deployment
exapand it.
3.select instant run. on right uncheck Enable Instant run to disable it.
4.you can see your connected devices log in Android Monitor.
Second way to connect mobile phone is over wifi
A. For un Rooted mobiles
1.your mobile phone and laptop/PC must be connected to same network.
2.First connect your mobile to PC via USB as above.
3.goto terminal window of android studio
type commands as follow.
adb tcpip 5555
press enter
4.following msg should displayed
restarting in TCP mode port: 5555
5.if you get msg like adb not found
then you need to add adb path to system variable.
6.adb path is
C:UsersUserAppDataLocalAndroidsdkplatform-tools
copy your path
7.Right click on computer icon on your desktop goto properties.
8.on left click Advanced system settings
9.System properties window will open
goto Advanced Tab
click Environment Variables
10.Under System variables.
look for path select then click edit
11.Edit system Variable
in variable value to goto end of line
appeend semocolon ‘ ; ‘
then paste path we copied .
12.click ok save all settting.
restart Android Studio.
now try again
your commands should work now
13.now look for ip of your mobile
goto setting about status
you will see your mobile ip address here.
my is 192.168.0.105
14.go back to terminal window
type following command
adb connect 192.168.0.105
press enter
connected to 192.168.0.105:5555
15.you will see your mobile is now connected and ready to use.
you can remove USB connected.
for this method you need to connect using usb for first time.
if you dont like this try second method but for this your mobile must be rooted
B. for rooted mobile
1.Download terminal emulator app from play store.
2.open and type or paste following commands one by one.
3.command
su
press enter you will need to accept super user permission
4.command
setprop service.adb.tcp.port 5555
enter
restart adbd by following command
5.command
stop adbd
press enter
6.command
start adbd
press enter
7.now in terminal window of android studio
type last command
adb connect 192.168.0.105
yes your mobile is now connected over WiFi without using USB cable.
(Tip: reserve your mobile IP address in WiFi router so it will never change and you don’t need to check every time you connect mob to PC.)
Happy coding.
If you like post don’t forget to subscribe us.
share with your friends.
and do follow us on Facebook, Twitter and Google plus.