Difference between revisions of "Creating a Kindle Fire Android Virtual Device (AVD)"
m (Text replacement - "<!-- Ezoic - BottomOfPage - bottom_of_page --> <div id="ezoic-pub-ad-placeholder-114"></div> <!-- End Ezoic - BottomOfPage - bottom_of_page -->" to "<htmlet>ezoicbottom</htmlet>") |
m (Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <table border="0" cellspacing="0"> | + | <table border="0" cellspacing="0" width="100%"> |
<tr> | <tr> | ||
<td width="20%">[[Setting Up a Kindle Fire Android Development Environment|Previous]]<td align="center">[[Kindle Fire Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Example Kindle Fire Android Application|Next]]</td> | <td width="20%">[[Setting Up a Kindle Fire Android Development Environment|Previous]]<td align="center">[[Kindle Fire Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Example Kindle Fire Android Application|Next]]</td> | ||
Line 241: | Line 241: | ||
<google>BUY_KINDLE_FIRE</google> | <google>BUY_KINDLE_FIRE</google> | ||
+ | |||
<htmlet>ezoicbottom</htmlet> | <htmlet>ezoicbottom</htmlet> | ||
<hr> | <hr> | ||
− | <table border="0" cellspacing="0"> | + | <table border="0" cellspacing="0" width="100%"> |
<tr> | <tr> | ||
<td width="20%">[[Setting Up a Kindle Fire Android Development Environment|Previous]]<td align="center">[[Kindle Fire Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Example Kindle Fire Android Application|Next]]</td> | <td width="20%">[[Setting Up a Kindle Fire Android Development Environment|Previous]]<td align="center">[[Kindle Fire Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Example Kindle Fire Android Application|Next]]</td> |
Latest revision as of 19:58, 27 October 2016
Previous | Table of Contents | Next |
Setting Up a Kindle Fire Android Development Environment | Creating an Example Kindle Fire Android Application |
<google>BUY_KINDLE_FIRE</google>
In the course of developing Android apps for the Kindle Fire it will be necessary to compile and run an application multiple times. An Android application for the Kindle Fire may be tested by installing and running it either on a physical device or in an Android Virtual Device (AVD) emulator environment. Before an AVD can be used, it must first be created and configured to match the specification of a Kindle Fire model. The goal of this chapter, therefore, is to work through the steps involved in creating such a virtual device.
About Android Virtual Devices
AVDs are essentially emulators that allow Android applications to be tested without the necessity to install the application on a physical Android based device. An AVD may be configured to emulate a variety of hardware features including options such as screen size, memory capacity and the presence or otherwise of features such as a camera, GPS navigation support or an accelerometer. As part of the installation process outlined in the previous chapter, a number of emulator definitions were installed allowing AVDs to be configured for the current range of Kindle Fire devices.
When launched, a Kindle Fire specific AVD will appear as a window containing an emulated Kindle Fire device environment. Figure 4-1, for example, shows an AVD session configured to emulate the Kindle Fire HD 7” device.
New AVDs are created and managed using the Android Virtual Device Manager, which may be used either in command-line mode or with a more user-friendly graphical user interface.
Figure 4-1
Creating a Kindle Fire AVD
In order to test the behavior of an application on the full range of Kindle Fire devices it will be necessary to create an AVD for each device configuration. At time of writing this consists of Kindle Fire (1st Generation), Kindle Fire (2nd Generation), Kindle Fire HD 7” and Kindle Fire HD 8.9” devices. For the purposes of this chapter, an AVD will be created configured to emulate the Kindle Fire HD 7” device.
In order to create a new AVD, the first step is to launch the AVD Manager. This can be achieved from within the Eclipse environment using the Window -> Android Virtual Device Manager menu option. Alternatively, the tool may be launched from the command-line using the following command:
android avd
Once launched, the tool will appear as outlined in Figure 4 2. Assuming a new Android SDK installation, no AVDs will currently be listed:
Figure 4-2
Begin the AVD creation process by clicking on the New… button in order to invoke the Create a New Android Virtual Device (AVD) dialog. Within the dialog, perform the following steps to create a Kindle Fire compatible emulator:
1. Enter a descriptive name (for example KindleFireHD7) into the name field. Note that spaces and other special characters are not permitted in the name. 2. Set the Device menu to Kindle Fire HD 7” (800 x 1280: hdpi). 3. Use the Target menu to select the option matching the Device setting, in this case the Kindle Fire HD 7” (Amazon) – API Level 15 target. 4. Set the CPU/ABI menu to ARM (armeabi-v7a). 5. Leave the default RAM value in Memory Options. 6. The VM Heap value should be set to 64MB for the Kindle Fire – 1st Generation and to 256MB for the Kindle Fire – 2nd Generation and Kindle Fire HD models. 7. Set Internal Storage to 1024 MiB. 8. If the host computer contains a web cam the Front Camera: emulation may be configured to use this camera. Alternatively, an emulated camera may be selected. If camera functionality is not required by the application, simply leave this set to None.
Whether or not you enable the Hardware Keyboard and Display skin with hardware controls options is optional. When the hardware keyboard option is selected, it will be possible to use the physical keyboard on the system on which the emulator is running. As such, the Kindle software keyboard will not appear within the emulator.
The skin with hardware controls option controls whether or not buttons appear as part of the emulator to simulate the hardware buttons present on the sides of the physical Kindle Fire device.
Note that it may also be possible to speed the performance of the emulator by enabling the Use Host GPU option. In the event that the emulator crashes during startup when this option is selected, edit the virtual device properties and disable this option.
Figure 4-3 illustrates the dialog with the appropriate settings implemented for a Kindle Fire HD 7” emulator. Once the configuration settings are complete, click on the OK button.
Figure 4-3
With the AVD created, the AVD Manager may now be closed. If future modifications to the AVD are necessary, simply re-open the AVD Manager, select the AVD from the list and click on the Edit… button.
Starting the Emulator
To perform a test run of the newly created AVD emulator, simply select the emulator from the Android Virtual Device Manager and click on the Start… button followed by Launch in the resulting Launch Options dialog. The emulator will appear in a new window and, after a short period of time, the “kindle fire” text will appear in the center of the screen. The first time the emulator is run, it can take up to 10 minutes for the emulator to fully load and start. On subsequent invocations, this will typically reduce to a few minutes. In the event that the startup time on your system is considerable, do not hesitate to leave the emulator running. The ADT system will detect that it is already running and attach to it when applications are launched, thereby saving considerable amounts of startup time.
Once fully loaded, the emulator will display either the standard Kindle Fire lock screen, or the home screen showing a small selection of pre-installed applications as previously shown in Figure 4-1.
Kindle Fire AVD Command-line Creation
As previously discussed, in addition to the graphical user interface it is also possible to create a new AVD directly from the command-line. This is achieved using the android tool in conjunction with some command-line options. Once initiated, the tool will prompt for additional information before creating the new AVD.
Assuming that the system has been configured such that the Android SDK tools directory is included in the PATH environment variable, a list of available targets for the new AVD may be obtained by issuing the following command in a terminal or command window:
android list targets
The resulting output from the above command will contain a list of Android SDK versions that are available on the system. For example:
Available Android targets: ---------- id: 1 or "android-10" Name: Android 2.3.3 Type: Platform API level: 10 Revision: 2 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854 ABIs : armeabi ---------- id: 2 or "Amazon:Kindle Fire:10" Name: Kindle Fire Type: Add-On Vendor: Amazon Revision: 3 Description: Android SDK Add-On for Kindle Fire Based on Android 2.3.3 (API level 10) Skins: WVGA854, WQVGA400, HVGA, KindleFire (default), WQVGA432, WVGA800, QVGA ABIs : armeabi Adds USB support for devices (Vendor: 0x1949) ---------- id: 3 or "android-15" Name: Android 4.0.3 Type: Platform API level: 15 Revision: 3 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800 ABIs : armeabi-v7a ---------- id: 4 or "Amazon:Kindle Fire (2nd Generation):15" Name: Kindle Fire (2nd Generation) Type: Add-On Vendor: Amazon Revision: 2 Description: Android SDK Add-On for Kindle Fire (2nd Generation) Based on Android 4.0.3 (API level 15) Skins: WVGA854, WQVGA400, WSVGA, WXGA720, HVGA, KindleFire (default), WQVGA432, WVGA800, QVGA, WXGA800 ABIs : armeabi-v7a Adds USB support for devices (Vendor: 0x1949) ---------- id: 5 or "Amazon:Kindle Fire HD 7":15" Name: Kindle Fire HD 7" Type: Add-On Vendor: Amazon Revision: 2 Description: Android SDK Add-On for Kindle Fire HD 7" Based on Android 4.0.3 (API level 15) Skins: WVGA854, WQVGA400, WSVGA, WXGA720, HVGA, KindleFire (default), WQVGA432, WVGA800, QVGA, WXGA800 ABIs : armeabi-v7a Adds USB support for devices (Vendor: 0x1949) ---------- id: 6 or "Amazon:Kindle Fire HD 8.9":15" Name: Kindle Fire HD 8.9" Type: Add-On Vendor: Amazon Revision: 3 Description: Android SDK Add-On for Kindle Fire HD 8.9" Based on Android 4.0.3 (API level 15) Skins: WVGA854, WQVGA400, WSVGA, WXGA720, HVGA, KindleFire (default), WQVGA432, WVGA800, QVGA, WXGA800 ABIs : armeabi-v7a Adds USB support for devices (Vendor: 0x1949) ----------
The syntax for AVD creation is as follows:
android create avd -n <name> -t <targetID> [-<option> <value>]
For example, to create a new AVD named KindleFireHD89 using the target id for the Kindle Fire HD 8.9” device (in this case id 6), the following command may be used:
android create avd -n KindleFireHD89 -t 6
The android tool will create the new AVD to the specifications required for a Kindle Fire HD 8.9” device. Once a new AVD has been created from the command line, it may not show up in the Android Device Manager tool until the Refresh button is clicked.
In addition to the creation of new AVDs, a number of other tasks may be performed from the command line. For example, a list of currently available AVDs may be obtained using the list avd command line arguments:
android list avd Available Android Virtual Devices: Name: KindleFireHD7 Path: C:\Users\nas\.android\avd\KindleFireHD7.avd Target: Kindle Fire HD 7" (Amazon) Based on Android 4.0.3 (API level 15) ABI: armeabi-v7a Skin: 800x1280 --------- Name: KindleFireHD89 Path: C:\Users\nas\.android\avd\KindleFireHD89.avd Target: Kindle Fire HD 8.9" (Amazon) Based on Android 4.0.3 (API level 15) ABI: armeabi-v7a Skin: 1200x1920
Similarly, to delete an existing AVD, simply use the delete option as follows:
android delete avd –name <avd name>
Android Virtual Device Configuration Files
By default, the files associated with an AVD are stored in the .android/avd sub-directory of the user’s home directory, the structure of which is as follows (where <avd name> is replaced by the name assigned to the AVD):
<avd name>.avd/config.ini <avd name>.avd/userdata.img <avd name>.ini
The config.ini file contains the device configuration settings such as display dimensions and memory specified during the AVD creation process. These settings may be changed directly within the configuration file and will be adopted by the AVD when it is next invoked.
The <avd name>.ini file contains a reference to the target Android SDK and the path to the AVD files. Note that a change to the image.sysdir value in the config.ini file will also need to be reflected in the target value of this file.
Moving and Renaming an Android Virtual Device
The current name or the location of the AVD files may be altered from the command line using the android tool’s move avd argument. For example, to rename an AVD named KindleFire2 to KindleFire3, the following command may be executed:
android move avd -n KindleFire2 -r KindleFire3
To physically relocate the files associated with the AVD, the following command syntax should be used:
android move avd -n <avd name> -p <path to new location>
For example, to move an AVD from its current file system location to /tmp/KindleFireTest:
android move avd -n KindleFire2 -p /tmp/KindleFireTest
Note that the destination directory must not already exist prior to executing the command to move an AVD.
Summary
A typical application development process follows a cycle of coding, compiling and running in a test environment. Android applications may be tested on either a physical Kindle Fire device or using an Android Virtual Device (AVD) emulator. AVDs are created and managed using the Android AVD Manager tool which may be used either as a command line tool or using a graphical user interface. When creating an AVD to simulate the Kindle Fire it is important that the virtual device be configured with a hardware specification that matches that of the physical device.
Now that we have created and configured an AVD, the next step is to create a simple application and run it within the AVD.
<google>BUY_KINDLE_FIRE</google>
Previous | Table of Contents | Next |
Setting Up a Kindle Fire Android Development Environment | Creating an Example Kindle Fire Android Application |