Android Emulator: You want to test your Android application but problem is that your application will run on multiple android devices like Tablet, TV, and Wear. So you have to buy this all? of course not because it’s not only device dependency, it’s also about OS version (KitKat, Lollipop, Marshmallow, Nougat, Oreo, Android P so many …). You can’t buy all devices to test App UI and Android application compatibility.
So Android Studio is providing Emulator which simulates various Phone, Tablets Wear OS (Watch) and TV on your system (computer or laptops). Each simulator of the Android Emulator uses an Android Virtual Device (AVD)
Some Android emulator features :
- Resize the window
- Adjust Volume
- Change orientation
- Zoom in – Zoom out
- Screenshots
- Drag and drop files in Emulator
- Install app used .apk File
- GPS Location
- Screen recording
- Virtual sensors
- Fingerprint
- Call Device
- Send Message
- Microphone
- Bug report
- Battery: Health, charge level, Status
- Simulate 2 fingers with multi-touch
- Simulate network: data, speed, and status
- Direction pad (TV apps)
Lot of things you can do with Android Emulator same as an android based device. This is basic understanding, now come to how could you use it in during building and test Android applications?
Setup Android Emulator :
Here is some step you have to follow to setup Android emulator, just follow it.
Step 1. Create a new project “Build Your First Android App in Kotlin“
Step 2. After creating the app you can see the Android Studio IDE environment
Click on “AVD Manager“, “Android Virtual Device Manager” Popup will open
Step 2. In “Android Virtual Device Manager” if there is already an android emulator there then it will show up otherwise nothing will show
Click on “Create Virtual device“
Step 3. “Virtual Device Configuration” -> “Select hardware”
You can select hardware as per requirements, I recommended using Nexus 5x because of its resolution, size, and density good for testing most android apps. You can choose any configuration as your requirements, just keep in mind use configuration as realistic device are available in the market and trading with your targeting audience.
- Category -> Phone
- Name -> Nexus 5x
Click on “Next“
Step 4. “Virtual Device Configuration” -> “System Image”
Here we have to choose which Android OS (Operation system) will use in Android Emulator.
There is 3 tabs option go with “Recommend”, other option x86 images and Other images can use as per requirements.
You have to download images, then after chose anyone as per requirements. In this example, we are using API 28.
Click on “Download” -> after download click “Finish“
Now you can see download images, select anyone (API 28) and then click on “Next“
Step 5. “Virtual Device Configuration” -> “Verify Configuration”
Give AVD name or leave it default. Click on “Finish“
Step 5. “Android Virtual Device Configuration”
You can see on Android Emulator on screen, Now in Action click in “Play” button and the Android emulator will launch in your computer.
Android Emulator After launch, Now you can test your app with it.
Run The android app In Android Emulator (Simulator) :
Everything is setup now you have to run the app in Emulator. Here is just a few steps to complete this chapter
Step 1. Click on “Run” Button in Android Studio IDE
Step 2. Select Emulator, you want to run for this app
** Selecting just we created and launched one,
Then just Click “OK“, That it! Done
Screenshot of the output of Android app in Android Emulator :
Note : This example (Project) is developed in Android Studio 3.0.1