Step 1:
Today we are learning how to make a virtual device if an Android phone is not available for testing an app. So in this way, we will create our own virtual machine and run the app on it, but one thing is that if you want to run a virtual device it will work more slowly than the real devices. Now go to the
Tools option, then
Android and then select the
AVD Manager.
Step 2:
After clicking the AVD Manager, if you are installing Android for the first time then this type of screen will appear and ask to create the virtual device; now click on this button.
Step 3:
Now select the device which you want to make a virtual device, but remember that you also test your app on tablet, TV and wear devices, so ad them this time. I choose the Nexus 5 device to run my app.
Step 4:
Now after clicking next you can see that the API level appears; if you agree to that level, then press the next button, but in left side you see that HAXMI is not installed in PC, so we have two options. One is to download the Intel HAXMI website, the second is to go to the SDK Manager and check HAXMI and install the package.
Step 5:
After clicking next now you choose the RAM and some memory configuration of virtual devices because if you want to run three virtual devices at a time you have to share the RAM equally.
Step 6:
Now click on finish button which appeas in the previous step, then after taking 2 to 3 minutes now the virtual device is created and now you will be able to use this device.
Step 7:
Now when you run the app you should see that it gives a message that Intel HAXM in properly installed so at this pint I have no HAXM software, so as I previously told you you have two options; one is to download independently and the second is go to the SDK manager and tick the checkbox of Intel HAXM and then install the package. After installation restart the Android studio.
Step 8:
After completing downloading we test our app. When you click on the run button it gives an option that you choose virtual device or real device. Mark on virtual device and press OK, then after that it takes three minutes. You see that your emulator appears and you application is running. Here is the preview of my app.