官术网_书友最值得收藏!

Setting up AVD for testing

AVDs are used to virtually test the app on your PC. You may not have different versions of Android with different screen resolutions. To overcome this issue, AVDs are used to virtually create a number of devices and test whether the app runs perfectly on a particular version of Android. One thing to note is that AVDs are much slower compared to physical devices. Now, let's create an AVD to test our Google Maps Android application. The AVD Manager looks a bit different in Android Studio than in the traditional one. There are two different targets of an AVD, they are:

  • Pure AOSP target, which does not contain any additional apps
  • Google API target, which has Google Play services preinstalled

The different architectures available are x86 and ARM.

Setting up AVD from Android Studio

In this section, we will set up AVD from the Android Studio IDE by performing these steps:

  1. Open AVD Manager in Android Studio by navigating to Tools | Android | AVD Manager. The following window will appear:
    Setting up AVD from Android Studio

    AVD Manager

  2. The following screenshot shows how to select the virtual device:
    Setting up AVD from Android Studio

    Selecting the virtual device

  3. The next step is to select a system image. The following window will appear. Select a system image with the Google APIs target. The x86 system images have better emulation speed than an ARM system image. Then, select Next.
    Setting up AVD from Android Studio

    Selecting the API target

  4. In the next screen, you can change some advanced settings. They are:
    • You can change the amount of RAM of your virtual device
    • You can change the internal and SD storage size
    • You can use your PC's webcam to support the Android camera
    • Enabling host GPU helps for better emulation speed as it uses your PC's graphics processor to render

    The following screenshot shows these additional options:

    Setting up AVD from Android Studio

    Additional options

  5. After changing the settings, finally select Finish. You will see a screen with a list of virtual devices created. To start a virtual device, press the green button under the Actions section.
    Setting up AVD from Android Studio

    Created AVD

It may take some time for the emulator to start according to the speed of your PC.

Setting up AVD from Android Studio

The preceding screenshot shows an emulator running Android Lollipop 5.0 with the Google API.

Setting up AVD from Eclipse

In this section, we will set up AVD from the Eclipse IDE by performing these steps:

  1. Let's see how to create an AVD from the Eclipse IDE. Open the AVD manager in Eclipse by navigating to Window | Android Virtual Device Manager.
  2. In the Android Virtual Device (AVD) Manager window, you will see the list of virtual devices created with the predefined device definitions.
    Setting up AVD from Eclipse

    AVD Manager

    The following screenshot shows the AVD Manager with the device definitions:

    Setting up AVD from Eclipse

    AVD Manager with device definitions

  3. To create a new virtual device, select a device configuration and click on the Create AVD button. The following window will appear. You can change the advanced configurations, amount of RAM, and so on.
    Setting up AVD from Eclipse

    Creating a new virtual device

  4. Then, press OK. Your virtual device will be created. The following window will appear with the list of virtual devices created:
    Setting up AVD from Eclipse

    Created virtual devices that are listed

  5. To start the virtual device, select a virtual device from the list and press the Start... button. The emulator will be running.
主站蜘蛛池模板: 会理县| 文水县| 福泉市| 镇雄县| 宾阳县| 宿松县| 德令哈市| 双流县| 五台县| 那坡县| 兴海县| 竹山县| 全南县| 芦山县| 三江| 涿鹿县| 阿拉善右旗| 康马县| 台中市| 叶城县| 文山县| 鹤壁市| 义马市| 余姚市| 基隆市| 乌拉特后旗| 阿城市| 天水市| 黄石市| 金沙县| 沙湾县| 浪卡子县| 龙岩市| 淳化县| 湘西| 航空| 怀来县| 布拖县| 扶余县| 修武县| 揭阳市|