Why use these Emulators :
Your App may support various flavors of Android Operating system versions depending upon what minSDK and maxSDK levels you set for your Application in AndroidManifest.xml file.
So if set minSDK as = 3 and maxSDK = 21 , you need to test your application on various OS versions like : Cupcakes, Froyo, Eclair, Gingerbread, Honeycomb, IceCreamSandwitch, Jelly Bean, Kitkat and the latest version i.e Android 5.0 Lollipop if applicable. If your are a small developer or a startup its for sure that you may not have these many devices running all various OS, so Emulators are best suited to test your App for compatibilities on various OS systems.
Further your App may support various screen sizes, so testing it on different screen sizes and resolutions is necessary , hence it is important to test it on screens ranging from 1.0" Android wears (if applicable) to 10.1" tablets or more!!
Emulators also provides debug capabilities like console logs and logs generated by the kernel.
How to create an Android Emulator Device AVD :
To create a new Android Emulator, you need to first start ADT eclipse . Go to the Menu -> Window, and select Android Virtual Device Manager
If it is the first time your are running the AVD Manager then you may not see any device listed under Android Virtual Devices Tab.
To create a new AVD , Click on Create button on the right.
Now the "Create new Android Virtual Device (AVD)" dialog comes up, with following fields and options,
1. AVD Name :
It is the name of the Emulator (you can keep any name you like)
2. Device :
This is a drop-down menu with with device options that are available to create an emulator with different screen sizes and resolutions.
List of devices Available :
3. Target :
It is the API level : OS version that your AVD device will run on. Remember that if you only get a single API when you install Android Development tool (ADT) mostly the latest one that is available when you downloaded it, if you download ADT it now you will only get API Level 21 : i.e. L Preview
4. CPU/ABI :
CPU/ABI : Application binary interface (ABI) is an interface between program like library and operating system modules at the system level, if you get the error here that "NO CPU/ABI System image available for this target" means that you do not any any CPU/ABI available/downloaded for a specific API level you have set as target. You need to go to "Android Device Manager" and download "Atom processor", "Intel Atom" or "ARM" for the Target API level that you have selected.
5. Keyboard :
Its is a check box to enable/disable hardware keyboard for the emulator that you are creating.
6. Skin :
Here you can set Hardware controls and skins, if you select dynamic hardware controls your emulator will have DialerPad, Call Pick/Drop, Back, Home and other options.
7. Front Camera :
You can set a front Camara (by default it is disabled) using this option. You can use your Webcam as camera or if you do not have an Webcam you can use an Emulated camera too.
8. Back Camera :
Like the front camera you can also set your back camera.
9. Memory Option :
You can select the RAM size here. If you want to test your App like games, for perforce on devices with a low RAM you can set the RAM to a lower value say 256MB.
You can also set the VM Heap size : Heap size that you allocate will be the max for Davlik VM available for your App. If you set it to a very low size then you may get the famous "Java Out of Memory exception" or Stack over flow exception"
10. Internal Memory :
Every mobile phone is shipped with an internal memory. You can set how much internal memory you need for your emulator here in MB/GB
Note : If you are on Windows and you set RAM more than 768MB then the emulator you create may fail and not laod. So it is advisable to set it a value less than 768MB.
11. SD Card :
You can even simulate SD cards (External memory sticks) by setting Size in MB/GB. This is important to test your App if it uses SD cards for read and write of data.
13. Emulation Options :
Here we have two Options :
a. Snapshot :
This is an important option when you create your AVD. If you enable this option the emulator RAM snapshot is saved when its 1st booted and hence when you boot your device next time it will be very quick compared to the time it will take when this option is not being selected (Just like the Hibernate option we have on Windows). So it is HIGHLY RECOMMENDED that you enable this option as if your hardware configuration is low, emulators may take 10-20 mins to boot up.
If you enable Graphical Processing Unit (GPU) you can use your computers OpenGL implementation. This will improve the graphics if you have a good GPU.
Note : You cannot use both of these options at a time. You can only use either of them.
We are done creating our Emulator , jus click OK, and you would see the emulator that you just created listed under "Android Virtual Devices".
Listed AVDs shows its Target Name, Platform, API level and CPU/ABI that you have selected, if you want to see all the setting using Detail Button.
If want to do some changes you can do it using Edit Option.
To launch the AVD click on Start. You will be prompted Launch Option.
Here you can scale-up/scale-down the emulator size, wipe data on it disable/enable Launch from Snapshot options.
Now, click Launch button to launch the Emulator,
If you have selected Skin with Hardware controls you would see Volume, Home and direction, search buttons on the right top corner.
The first boot may take a little longer to load.
Running you Application on Emulator
In order to run your Application Right Click on your Application Project Folder and click on Run As -> Run Configuration. If you only have a single Emulator you can select Run As -> Android Application, but if you have multiple Emulator or you have attracted your device via USB cord then its better to go to run configurations.
Here we have Options,
1. Always prompt to pick device :
When you select this option, you would always be prompted devices to choose from option when you run the project.
2. Launch on all compatible devices and AVDs
When selected all the emulators that are compatible with your Project will be launched.
3. Automatically pick compatible device. Always uses preferred AVD if set below, launches on compatible device/AVD otherwise.
Here you would see all the AVDs that you have created, the one that you select here will be Automatically picked when you run your project.
You can also add Additional Emulator Command line options.
Creating AVD from Device Definition Option
This is the most easiest way to create an emulator that simulates a real Google device like Nexus Phones, Tables, Wears or TVs.
Just select the Device and you will get the AVD Configuration screen populated with configuration that matches the real device.