Android : Emulators

In the last post we saw how to make a emulator from Android studios and run your app on it. You can make multiple emulator for different phones and can run more than one emulator also.


Notice the port number of both the emulators running. You can send sms, calls using these port numbers as the phone numbers in your emulators to check how your app responds to these events. As you know that emulators are slow , thus it is not advisable to run multiple emulators.

You can connect to youremulator via telnet and send commands in order to simulate events such as sms messaging, call, GPS coordinate changes etc. Now I am using windows and telnet is not installed by default. You first need to enable telnet. You can google for installing telnet. I found an one line command that will install the same, however an admin level access is required for it. At an administrative level command prompt, simply run:

>dism /online /Enable-Feature /FeatureName:TelnetClient

Telnet will be available immediately after the dism command has completed running.

To begin make sure your android emulator is running, then in a console:

>telnet localhost 5554

This will connect you to the emulator (note that the port 5554 may change depending on your setup. This port will be in the title of the emulator.) From here you can type help to list all the possible commands.
For example :
sms – will send message from 77777 to the emulator
gsm – will call the emulator from 77777
power – to simulate power conditions
avd stop/start – to pause/start the emulator.
It will be must faster to test our app, if we have a physical device. While plugging in the device via USB gives you access to the files stored on the device, it does not enable your app to be deployed on it.
Remember that we installed Google USB driver from Extra in last post. If you have not downloaded it, open SDK manager -> Go to Extras and install ‘Google USB driver’
I am not sure on this, the above process just download the files but does not install them. For that you have to go to your SDK folder and install them manually. For windows 8.1 the path for sdk is like this:
If you navigate to that folder, you will need to right click on the android_winusb.inf file and install the drivers.
Hit “Install” on this prompt and you are done for the Windows side.
After the drivers are successfully installed on your PC, you will need to enable the “Developer Options” on your mobile. I am using Nexus 5. From KitKat version, ‘Developer Options’ is hidden by default. To enable it, go to:
Settings -> About Phone -> Build number (Tap the build number 7 times.)
If done successfully, you will now see the “Developer options” at the bottom of the settings menu. Tap on it and place a checkmark on “USB Debugging”.
Now connect your device to your USB port on your computer and you should get the following screen:
Place a checkmark in the “Always allow from this computer” and hit “OK”. You are now free to open Android Studio and run your app on your local device!
Default emulator is slow, and you cannot have many devices to test your app on. There is a third party emulator called Genymotion that we can use instead the previous ones. It is much faser and smoother. It runs as a virtual machine on your computer which brings better performance. It is free for developers with limited features but its still worthwhile.
Download Genymotion from here. You have to create a free account tough. It requires oracle virtual box to run on, so download the bundled verrsion with orcle virtual box one. After the download simply do next next.
Now you have to install Genymotion plugin on to your Android Studio. Got to File -> Settings – > plugins
After the installation , restart Studio and you can now see the plugin in home screen:
Clicking on it for the first time will ask you the path of the installtion, which is usually something like this :
C:\Program Files\Genymobile\Genymotion
Launch Genymotion again.
Click on new and you can create a emulator just like the default emulator in studio. You may have to sign in first.
Click Next. Enter the name and click next again. It will download the required files and Add the Emulator. To start simply click start.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: