Skip to main content

Creating Android Virtual Devices (AVDs)

The next step is to create an Android Virtual Device (AVD) you can use for testing your Android application. An AVD is an emulator instance that enables you to model an actual device. Each AVD consists of a hardware profile ; a mapping to a system image ; and emulated storage,such as a secure digital (SD) card.One important thing to remember about emulators is that they are not perfect. There are some applications , such as games (which are GPU heavy ) or application that use sensors such as the GPS or accelerometer. Theses types of application cannot be simulated with the same speed or consistency within an emulator as they can when running on an actual device. However , the emulator is good for doing some generalized testing of your applications.

You can create as many AVDs as you want to test your applications with different configurations. This testing is important to confirm the behavior of you application when it is run on different devices with varying capabilities.


Use the following steps to create AVD. This example demonstrates creating AVD (put simply,an Android emulator) that emulates an Android device running Android N on the Nexus 5x hardware specs.

1. Start Android Studio so that the welcome screen is visible.Click Start a New Android Project. You see the Create New Project Wizard.

2. Set up a HelloWorld project. Type Helloworld in the Application Name field.

3. You can keep the default values for the fields on the New Project screen.Click next.

NOTE :- For the purposes of setting up a quick Hello World project and creating an AVD , you will be accepting many of the default values,without explanation, during the project setup process. This is fine for now,as all of the setting are explained in much greater detail in subsequent Blog.

4. You should see the Targeted Android Devices screen. By default , the Create New Project Wizard selects for you the Android SDK level that has greatest activity based on statistics gathered from Google Play. At the time this blog was written 74.3 percent of the active devices on Google Play were written using Android Jelly Bean. For now,accept the default show , and click Next.


5. On the Add an Activity to Moblie screen , accept the default choice - Empty Activity and click Next.


6. Accept all of the defaults on the Customize the Activity screen, as show , and click Finish. show the open Android Studio IDE.


7. Launch the AVD Manager by selecting tool -> Android-> AVD Manager or using the AVD Manager button from the toolbar. As shows the Android Virtual Device Manager Wizard , which is where you set up AVDs to be used when you emulate your application in Android on your desktop.


8. Click the + Create Virtual Device button to create a new AVD. the Virtual Device Configuration screen opens as show.


9. Select the Nexus 5x hardware profile and click Next. Although none of the emulators offers the same performance as its actual hardware counterpart , the Nexus 5x should run well on most x86-based desktops, and it still offers some of the mid -to high-end Android Device specs.

10. For the system image , select and install the latest the latest option, which at the time this blog was written is Android Nougat . Click the x86 Images tab , select N from the list of images , and then click Next.


11. In the Android Virtual Device (AVD ) dialog , accept the defaults as show figure Click the Finish button to begin building the AVD.

TIP :- it is preferable to create a few AVDs with different API levels and hardware configurations so that your application can be tested different version of the Android OS.


 

Comments

Popular posts from this blog

Applying Styles and Themes to an Activity

By default , an activity is themed to the default Android theme. However , there been a push in recent year to adopt a new theme known as Material . The Material theme has a much more modern and clean look to it. There are two versions of the Material theme available to Android developers : Material Light and Material Dark , Either of these themes can be applied from the AndroidManifest.xml To apply one of the Material themes to an activity , simply modify the <Application> element in the AndroidManifest.xml file by changing the default android:theme attribute. (Please be sure to change all instances of "com.android" to whatever package name your project is using.) <?xml version="1.0" encoding="utf-8"?> <manifest xmls:android="http://schemas.android.com/apk/res/android"        xmlns:tools="http://schemas.android.com/tools"        package="com.android.activity101">        <application ...

Using Code Completion

Code completion is an invaluable tool that shows you contextual options for completing the piece of code that you are trying to write. For example, in the editor tab for the MainActivity.js file, locate the line that reads.          setContentView(R.layout.activity_main); Place your cursor after this line and press the Enter Key . On the new line , type the letter R , and then type a period, as shown here:          R. Android Studio Code Completion should display a list of values that you could use to try to complete the code statement. Figure shows what this list might look like . this is important if you are not entirely sure of the spelling of a method call or how to identify the different method signatures. NOTE if the code completion window does not open , press Ctrl + Space to force it to open. This is the same key combination used in some other IDEs for their versions of the code complet...

Now in Android

Android Studio 4.2 discharged to steady channel   Android Studio 4.2 is now available in the stable release channel. Read the blog for detailed information on what’s new, including a new tool to help migrate your project to the latest Android Gradle Plugin version. We’ve also enhanced lots of stuff such as Database Inspector , System Trace , SafeArgs support, Apply Changes, and the new project wizard. As always, download here and file issues here .           Hilt is stable and ready for production Manuel Vivo wrote about the stable release of Hilt , Android Jetpack’s recommended dependency injection (DI) solution for Android apps. Hilt is a simpler, more opinionated way to leverage the power of the Dagger DI library, eliminating boilerplate and reducing errors. It provides direct injection support for popular Jetpack libraries such as ViewModel, WorkManager, Navigation, and Compose. ( DI Basics , Documentation )   Google Play updates ...