Author: Costas Styliano
Abstract:
If you are an Android * developer and are not satisfied with the performance of the Android simulator, read this article. We often hear many Android Developers complain that the simulator is slow and difficult to operate, but this is not the case! If you are using a new computer that uses Intel processor and supports intel virtualization technology and runs Microsoft Windows * or Apple Mac OS *, you can use intel hardware accelerator execution Manager (Intel HAXM) or KVM for Linux * to greatly improve the performance of the Android simulator, thus speeding up the testing and debugging of Android applications. This article describes in detail the steps required by the accelerator simulator and how to operate it. Next, we will introduce how to use NDK to compile the x86 native code and how to submit the APK containing the x86 native Library to the Google Play Store. Intel HAXM can also be used to accelerate the Tizen * simulator, but this is not covered in this article. For more information, visit tizen.org.
Directory
1. Introduction
2. Installation
2.1. Prerequisites
2.2. install on Windows
2.3. Install
2.3.1. KVM Installation
2.4. Create AVD (Android * virtual device)
3. recognized best practices
3.1. Use a simulator to test applications in Eclipse
3.2. Submit multiple APK files for different ABI and submit fat binary files to Google Play
3.3. Compile the x86-oriented NDK
3.3.1. Add the NDK path to the Environment Variable
3.3.2. Compile with NDK
3.3.3. Other Methods compiled using NDK
1. Introduction
This article provides guidance on installing intel hardware accelerator execution Manager (Intel HAXM. Intel HAXM is a hardware-assisted virtualization engine (hypervisor) that accelerates Android * development through Intel virtualization technology (Intel VT) on Windows. In addition, it describes how to install hardware-assisted KVM on Linux * and how to use the accepted best method for native compilation and submit the application to the Google Play Store for x86.
2. Install 2.1. Prerequisites
- You must install the Android SDK.
- Your computer must use an Intel processor and support Intel VT-x, EM64T, and virus protection technology (XD) features enabled through BIOS.
2. install on Windows
After installing the Android SDK, open the SDK manager. In the additional section, you can find intel HAXM.
Check the box and click "Install packages ..." Button. After the software package is Installed, the status is displayed as "Installed". This is misleading, but not true. The SDK only copies intel HAXM executable files on your device, and whether or not these executable files are installed depends on you.
To install the Intel HAXM executable file, search for IntelHaxm.exe on your hard disk (search IntelHAXM. dmg on Mac OS X ). If you set it to the default value, the file should be located in the following directory: C: \ Program Files \ Android \ android-sdk \ extras \ Intel \ Hardware_Accelerated_Execution_Manager \ IntelHaxm.exe.
Can intel HAXM communicate with intel only? The x86 processor system image is used together. This image can be used for Android 2.3.3 (API 10), 4.0.3 (API 15), 4.1.2 (API 16), and 4.2.2 (API 17 ). Using the SDK manager, these Intel System images are installed in the same way as ARM-based images.
When you click the IntelHaxm executable file, the following welcome page is displayed:
You can adjust the RAM memory capacity allocated to Intel HAXM. Click "Next ". The next interface confirms the memory allocation. If your requirements are met, click "Install ".
To be able to install intel HAXM, you must enable intel VT-x in BIOS; otherwise, the following errors may occur during installation:
If this error occurs, enter and enable your BIOS.
The second method for downloading the system images of Intel HAXM and x86 simulators is to directly access the following website: http://software.intel.com/en-us/androidand download the necessary components from this website.
2.3. Install
The steps to improve the performance of Linux-oriented Android simulators are different from those of Windows and Mac OS X. Because intel HAXM is incompatible with Linux, you need to use KVM (kernel-based Virtual Machine) instead. The following describes how to use Ubuntu * 12.04, which may be slightly different from other Linux versions.
When operating in Windows (and Mac OS X), you must first download the Android SDK from the Android developer site. You will see an ADT (Android developer tool) package, which includes Eclipse * IDE and Android SDK. Download the zip file and decompress it to your Linux device. Make sure that you have selected a file suitable for your Linux version, 32-bit or 64-bit. You can run the following command to check this information:
File/sbin/init
Before starting to install the software packages required by KVM, we recommend that you confirm that you have the latest library. You can run the following command to confirm the installation:
Sudo apt-get update
2.3.1. KVM Installation
To install and run KVM (a Linux-oriented full virtualization solution based on x86 hardware, Intel VT), first check whether your CPU supports hardware virtualization. You can confirm by entering the following command:
Egrep-C' (vmx | svm) '/proc/cpuinfo
If the result is 0, it indicates that your CPU does not support hardware virtualization, and hardware virtualization is a necessary condition for running KVM. If the result is 1 or greater than 1, it indicates that you can install and run KVM, but you still need to confirm whether this feature has been enabled in BIOS (see section 2.2 ).
Next, if you have not installed KVM, install it. You can run the following command to check whether your processor supports KVM:
Kvm-OK
If you already have KVM, you will see:
"INFO: Your CPU supports KVM extensions
INFO:/dev/kvm exists
KVM acceleration can be used"
Otherwise, if you see the following message, you need to enter the BIOS and enable intel VT:
"INFO: KVM is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT ),
And then hard poweroff/poweron your system
KVM acceleration can NOT be used"
Next, you need to install KVM and several other required software packages. To do this, enter:
Sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
In the next window, if you do not want to change the configuration, you can select "No configuration ":
Then, add your users to the KVM group and the libmongod group. To do this, enter:
Sudo adduser your_user_name kvm
Sudo adduser your_user_name libmongod
After the installation is complete, log on again to make the change take effect. Run the following command to test the installation:
Sudo virsh-c qemu: // system list
Now you can proceed to the next step, that is, creating and running AVD (Android virtual machine ). This step is the same for Linux and Windows.
2.4. Create AVD (Android * virtual machine)
After installing the SDK and Intel HAXM (or Linux KVM), you can create a virtual device with hardware acceleration simulation. To perform this operation, go to the AVD manager and create a new device. Make sure to select intel lingdong (x86) as the CPU/ABI. Once an intel x86 system image is installed, the selection is displayed in the drop-down menu to smoothly switch other graphics on the GPU simulation when an AVD is created.
Click "New" and create an x86 AVD. Make sure you have selected an API supported by the x86 system image, set CPU/ABI to x86, and enabled GPU (OpenGL ES *) simulation. After completing this operation, click "Create AVD" to Create an AVD.
You can click "Start" and "Launch" in sequence to Start the x86 AVD.
If you have successfully installed the SDK, a dialog box is displayed when the simulator is started, showing that Intel HAXM is running in fast virtual mode.
If you need to further confirm whether you are using an x86 system image, you can view the details in "About phone" in the simulator.
The performance of Intel HAXM or KVM depends on your computer, hard disk, and memory, but it will increase by 5 to 10 times. The following shows a detailed comparison between AVD supported by x86/HAXM and AVD based on ARM. X86 AVD enters the lock status within 15 seconds, rather than 40 seconds for Intel AVD, which is a significant difference.
[According to your system configuration, Intel HAXM (or KVM) performance will be improved by 5 to 10 times: the software involved in the Performance Testing Process and its performance can be optimized only in the Intel microprocessor architecture. Tests such as SYSmark * And MobileMark * are based on specific computer systems, components, software, operations and functions. Changes to any of the above elements may lead to changes in the test results. Refer to other information and performance tests (including running performance when used in conjunction with other products) to fully evaluate the target product. Configuration: in this case, use Mac Book Pro for testing. For more information, visit http://www.intel.com/performance].
3. recognized best method 3.1. Use a simulator to test applications in Eclipse
Whether it's an NDK-based application or a Dalvik * application, you can use intel HAXM to improve the performance of the simulator you use for testing. If you are using Eclipse for development, you can follow these simple steps to confirm that you are using Intel HAXM when starting the simulator.
First, confirm that you have created AVD as described in step 2. If you have created an AVD, go to "Run As-> Run Config", As shown below:
You should enter a page similar to the following:
You can select the corresponding box and select the AVD you want. After creating an AVD and configuring it, you can select "Run As-> Android Application" and use the simulator to compile and debug the project. This will automatically enable hardware acceleration AVD.
After the AVD is started, you can see the main interface of the application (after the screen is unlocked ).
3.2. Submit multiple APK files for different ABI and submit fat binary files to Google Play
In the past, you had to submit a fat binary file for the developed application, which should contain all libraries and NDK files and cannot distinguish between architectures. This means that you must download the entire APK, but some of the files are not associated with the specific architecture, that is, x86 users may have ARM code, and vice versa. The disadvantage is that if you have a fat binary file, it forces users to download a large amount of data, which may not be suitable for devices. Generally, it is acceptable if your APK is smaller than 10 to 20 MB.
Intel/Google has implemented the CPU filtering mechanism. That is to say, you can follow the recommended version code (as shown below) to submit multiple APK files containing different libraries for each architecture.
The first digit represents ABI (6 represents x86), then the API level (11) you need, the screen size (13), and the application version number 3.1.0.
Make sure that you have at least one eight-digit version number and assign the highest first digit to the x86 version. In the preceding example, you must enter 6 to represent x86, 2 to represent ARMv7, and 1 to represent ARMv5TE. In this way, the x86 version will become the first choice for x86 devices, and the ARM version will become the first choice for ARM devices.
Follow these guidelines to determine that your users will achieve the best performance on their own devices. In addition, you can avoid trying to run applications on a specific device due to code conversion issues.
For more information, visit.
3.3. Compile the x86-oriented NDK
This section describes how to compile the NDK section of your application for x86.
To enable NDK-based applications to run on x86 AVD, You need to compile the NDK library for the x86 architecture. To do this, take the following simple steps:
Open a command prompt and navigate to the folder where your NDK file is located, as shown below:
Make sure that you have set the environment variable path to use the ndk-build script from any location.
3.3.1. Add the NDK path to the Environment Variable
To set environment variables for NDK. Right-click "Computer" and select "Properties ". Go to "Advanced system settings" and find the environment variable. Select "Path" and click "Edit ". At the end of the Variable Value string, add the path to the root folder of the NDK that contains the ndk-build.cmd file, as shown in:
3.3.2. Compile with NDK
Navigate the command prompt to the NDK folder and run:
Ndk-build APP_ABI: = all
This will compile the NDK file for various architecture variables, including ARMv5TE, ARMv7, x86, and mips.
To compile a specific architecture, replace "all" with different architectures. For example:
Ndk-build APP_ABI := armeabi armeabi-v7a x86 mips
Make sure to refresh the project in Eclipse to get the latest settings, that is, the latest folder created by the ndk-build script. Now, you can see four folders in the project folder library, one folder for each architecture.
Now, you can use your NDK application in x86 AVD.
3.3.3. Other Methods compiled using NDK
There is another way to compile native code for all architectures (including x86), that is, to modify the Application. mk file, which is located in the jni folder. If you do not have the Application. mk file, you can create one and add the following command:
APP_ABI: = armeabi armeabi-v7a x86 mips
In this way, when the files are processed in batches (that is, the ndk-build script), the libraries will be compiled for all available architectures.
In addition, to simplify the application, you can enter "all" instead of listing all the architectures:
APP_ABI: = all