Using Intel HAXM for Android Wear and TV App Development
- Transfer
Android platform has a long way to go. It all started with smartphones, then there were tablets, then there were devices running Google TV, Android Wear, Android TV (instead of Google TV), and finally Android Auto. Building and testing applications that are designed for all this diversity can be challenging for developers. And if you add here various form factors and screen resolutions of devices, you can quickly encounter the problem of comprehensive verification and testing of programs. How to be? Fortunately, we have Intel HAXM .
Intel Hardware Accelerated Execution Manager (HAXM) is an Android emulator that supports hardware virtualization. It creates a low load on the system, has excellent performance and a fast interface.
Using Intel HAXM, you can run several instances of the Android emulator on one computer without worrying about performance, system load, or interface “brakes”. Such an approach can be very useful in the iterative process of creating and testing applications, it can give a huge increase in the productivity of developers.
Images of Android emulators designed for architectures other than x86 can start slowly and respond to user commands with a delay. In addition, unlike some third-party Android emulators, using Intel HAXM you get the opportunity to work with the latest versions of the API and Android platforms immediately after their release.
Here you can find detailed HAXM tutorials.
In this article, we’ll talk about how to use the capabilities of Intel HAXM to create applications designed for all kinds of Android platform options. Such applications can work on ordinary smartphones of various form factors, and on devices that carry Android Wear and Android TV on board.
Google recently released an application that shows how to cover many different Android devices with one code base.
The example demonstrates advanced approaches to the development of universal applications. To build a project, use the instructions that can be found at the above link. We, in this practical guide, will try an example on x86 HAXM emulators of Android TV, Wear and a smartphone.
The project can be imported into Android Studio and take advantage of the capabilities of this environment to build and run the application on the emulator. If you prefer to work with another IDE, then what will be discussed later will also be useful.
If the command line interface is close to you, you can simply run the Gradle script to build the application from the folder with the source code of the example.
The resulting APK file can be found in the folder “mobile / build / outputs / apk / mobile-debug.apk”.
First you need to make sure that we have the latest emulator images for Android TV, Wear, as well as for ordinary smartphones.
Open the Android SDK Manager. It can be launched from the Android Studio interface or from the command line (folder/ tools should be specified in environment variables) using this command:
Android SDK Manager window. The images of the systems that need to be loaded are highlighted.
After the necessary packages have been downloaded, you must configure the emulator configurations (that is, create an AVD set) to use the appropriate system images. To do this, we need the Android Virtual Device Manager. Run it from the command line:
Android Virtual Device Manager window, here you can create new AVDs and configure existing ones
We will configure the virtual device for Android Wear as shown in the figure below.
Configuring the emulator configuration for Android Wear
After the settings are completed, click OK, and then - run the emulator. To do this, select it in the AVD Manager window and click on the Start button. This is what the emulator window looks like.
Android Wear emulator window
In order for the smartphone to interact with a device running Android Wear (or with the corresponding emulator), you need an additional application . The only way to install this application on your device is to download from the Google Play Store. Accordingly, we will need an Android smartphone that has access to the Store.
The device must be available for ADB. In order for it to be able to connect to the emulator, it is necessary that both the smartphone and the emulator are present in the list of devices, which can be obtained with the following command:
List of connected devices
Now we redirect the TCP ports with this command:
Now everything is ready to pair the Android Wear emulator and the hardware device. It remains only to launch the Android Wear application on the smartphone, and, from its menu, execute the command to connect to the emulator. If the connection is successful, the emulator screen will look like the one shown on the left side of the picture. The right side shows the screen of an emulator that is not connected to a smartphone.
Android Wear emulator screens in connected (left) and unconnected (right) state
Detailed information on creating Android Wear applications can be found here . The APK file of the test application is no different from other APKs, it can be installed on the Android Wear emulator using ADB.
You can check if the application is installed on the emulator using the following command:
Installing the application on the emulator and verifying the installation
The name of the sample application package (com.example.android.uamp) is listed. From the command line, you can start the application:
Now the application is running on the Android Wear emulator
Let's create the virtual device configuration for Android TV as shown in the figure below.
Configuring the emulator configuration for Android TV
After setting, click on the OK button and start the emulator with the Start button in the ADV Manager window.
You can check the availability of the emulator for ADB with the following command:
Write down or remember the emulator identifier (something like emulator-55xx). It will be needed to indicate the target device when working with the emulator using ADB. To install the application on the emulator, you can use the following command:
You can run the application on the Android TV emulator like this:
This is how the application looks on the emulator screen.
Application running on Android TV emulator
If during the development and testing of the application there is a need to create and run several instances of emulators - all this is achievable using Intel HAXM. When installing HAXM, you can configure the size of RAM that is allocated for its operation. Here is the set of AVD configurations for Android Wear, TV and smartphone.
List of Android virtual devices
Below you can see an example application running simultaneously on three virtual devices (Android TV, Wear and a smartphone emulator). It also shows information about CPU usage. As you can see, all these instances of the emulator do not create excessive load on the system.
Three simultaneously running emulators and information about the load on the system that they create
In the process, you can configure the allocation of memory for emulators, optimizing their consumption of system resources. In order to reconfigure the memory allocation parameters specified during the HAXM installation, you must restart its installation and specify the necessary parameters.
In this article, we demonstrated the core capabilities of Intel HAXM. Here you can find details about using and configuring Android emulators. In order to verify the correct installation of HAXM, as well as whether it is used when working with emulators, refer to this material . We hope that Intel HAXM will become your reliable assistant in the development of Android applications for a wide variety of devices running on this platform.
Preliminary information
Intel Hardware Accelerated Execution Manager (HAXM) is an Android emulator that supports hardware virtualization. It creates a low load on the system, has excellent performance and a fast interface.
Using Intel HAXM, you can run several instances of the Android emulator on one computer without worrying about performance, system load, or interface “brakes”. Such an approach can be very useful in the iterative process of creating and testing applications, it can give a huge increase in the productivity of developers.
Images of Android emulators designed for architectures other than x86 can start slowly and respond to user commands with a delay. In addition, unlike some third-party Android emulators, using Intel HAXM you get the opportunity to work with the latest versions of the API and Android platforms immediately after their release.
Here you can find detailed HAXM tutorials.
In this article, we’ll talk about how to use the capabilities of Intel HAXM to create applications designed for all kinds of Android platform options. Such applications can work on ordinary smartphones of various form factors, and on devices that carry Android Wear and Android TV on board.
Work with a universal example application for Android
Google recently released an application that shows how to cover many different Android devices with one code base.
The example demonstrates advanced approaches to the development of universal applications. To build a project, use the instructions that can be found at the above link. We, in this practical guide, will try an example on x86 HAXM emulators of Android TV, Wear and a smartphone.
The project can be imported into Android Studio and take advantage of the capabilities of this environment to build and run the application on the emulator. If you prefer to work with another IDE, then what will be discussed later will also be useful.
If the command line interface is close to you, you can simply run the Gradle script to build the application from the folder with the source code of the example.
gradlew assembleDebug
The resulting APK file can be found in the folder “mobile / build / outputs / apk / mobile-debug.apk”.
Create AVD for Android TV and Wear
First you need to make sure that we have the latest emulator images for Android TV, Wear, as well as for ordinary smartphones.
Open the Android SDK Manager. It can be launched from the Android Studio interface or from the command line (folder
> android
Android SDK Manager window. The images of the systems that need to be loaded are highlighted.
After the necessary packages have been downloaded, you must configure the emulator configurations (that is, create an AVD set) to use the appropriate system images. To do this, we need the Android Virtual Device Manager. Run it from the command line:
> android avd
Android Virtual Device Manager window, here you can create new AVDs and configure existing ones
Android Wear emulation
We will configure the virtual device for Android Wear as shown in the figure below.
Configuring the emulator configuration for Android Wear
After the settings are completed, click OK, and then - run the emulator. To do this, select it in the AVD Manager window and click on the Start button. This is what the emulator window looks like.
Android Wear emulator window
In order for the smartphone to interact with a device running Android Wear (or with the corresponding emulator), you need an additional application . The only way to install this application on your device is to download from the Google Play Store. Accordingly, we will need an Android smartphone that has access to the Store.
The device must be available for ADB. In order for it to be able to connect to the emulator, it is necessary that both the smartphone and the emulator are present in the list of devices, which can be obtained with the following command:
> adb devices
List of connected devices
Now we redirect the TCP ports with this command:
> adb -d forward tcp:5601 tcp:5601
Now everything is ready to pair the Android Wear emulator and the hardware device. It remains only to launch the Android Wear application on the smartphone, and, from its menu, execute the command to connect to the emulator. If the connection is successful, the emulator screen will look like the one shown on the left side of the picture. The right side shows the screen of an emulator that is not connected to a smartphone.
Android Wear emulator screens in connected (left) and unconnected (right) state
Detailed information on creating Android Wear applications can be found here . The APK file of the test application is no different from other APKs, it can be installed on the Android Wear emulator using ADB.
> adb -s emulator-5554 install -r mobile\build\outputs\apk\mobile-debug.apk
You can check if the application is installed on the emulator using the following command:
> adb -s emulator-5554 shell pm list packages | grep example
Installing the application on the emulator and verifying the installation
The name of the sample application package (com.example.android.uamp) is listed. From the command line, you can start the application:
> adb -s emulator-5554 shell monkey -p com.example.android.uamp -c android.intent.category.LAUNCHER 1
Now the application is running on the Android Wear emulator
Android TV emulation
Let's create the virtual device configuration for Android TV as shown in the figure below.
Configuring the emulator configuration for Android TV
After setting, click on the OK button and start the emulator with the Start button in the ADV Manager window.
You can check the availability of the emulator for ADB with the following command:
> adb devices
Write down or remember the emulator identifier (something like emulator-55xx). It will be needed to indicate the target device when working with the emulator using ADB. To install the application on the emulator, you can use the following command:
> adb -s emulator-55xx install -r mobile/build/outputs/apk/mobile-debug.apk
You can run the application on the Android TV emulator like this:
> adb -s emulator-55xx shell monkey -p com.example.android.uamp -c android.intent.category.LAUNCHER 1
This is how the application looks on the emulator screen.
Application running on Android TV emulator
Create and run the required number of instances of emulators
If during the development and testing of the application there is a need to create and run several instances of emulators - all this is achievable using Intel HAXM. When installing HAXM, you can configure the size of RAM that is allocated for its operation. Here is the set of AVD configurations for Android Wear, TV and smartphone.
List of Android virtual devices
Below you can see an example application running simultaneously on three virtual devices (Android TV, Wear and a smartphone emulator). It also shows information about CPU usage. As you can see, all these instances of the emulator do not create excessive load on the system.
Three simultaneously running emulators and information about the load on the system that they create
In the process, you can configure the allocation of memory for emulators, optimizing their consumption of system resources. In order to reconfigure the memory allocation parameters specified during the HAXM installation, you must restart its installation and specify the necessary parameters.
Summary
In this article, we demonstrated the core capabilities of Intel HAXM. Here you can find details about using and configuring Android emulators. In order to verify the correct installation of HAXM, as well as whether it is used when working with emulators, refer to this material . We hope that Intel HAXM will become your reliable assistant in the development of Android applications for a wide variety of devices running on this platform.