Compile Windows Android Emulator (Cupcake)

Source: Internet
Author: User

 

The Android SDK provides a Qemu-based simulator to simulate Android smartphones. Thanks to the cross-platform features of Qemu, users of Linux, Mac OS, and Windows can greatly improve development efficiency through simulators. However, in the final analysis, Qemu is still a program developed on Unix-like platforms, so compilation on Windows platforms is worth looking. When Google described how to compile the Android Eclipse plugin ADT on git, it mentioned how to build the Android SDK for Windows, some Chinese friends wrote an article about building the Android SDK for Windows (this is a post, and the original author's blog is no longer accessible, however, there is no official document on how to build a Windows Android simulator. William only finds some fragmented discussions on the Internet, today, we will combine our own practices to share with you.

Two methods for compiling Android simulators in Windows

The make_windows_sdk.sh script for building the Windows SDK provided by Android contains make-j 4 emulator, which is the command for compiling the simulator. It seems that the simulator can be built in the Cygwin environment. In addition, because the Android simulator is based on Qemu, Android only adds new Virtual Devices and defines its own skin mechanism, as long as it is a standard Qemu environment that can be compiled normally, there is no problem with the Android simulator. The QEMU forum has a very detailed article about Qemu compilation in Windows. Step-by-step QEMU compilation under Windows is completed in MinGW/MSYS, therefore, it is feasible to build in the MinGW/MSYS environment.

Since Cygwin dependent on make_windows_sdk.sh looks more like an environment for official SDK production, it should be almost 100% working. Next, let's try unofficial practices first.

Prepare the MinGW/MSYS Environment

The MinGW and MSYS environments are not complex. The official website also provides detailed help documents. The following describes the installation process.

The installation packages to be downloaded include:
1、MinGW-5.1.4.exe, which is the Automatic Installation Tool of MinGW (Automated MinGW Installer)
2、MSYS-1.0.11.exe
3, msysDTK-1.0.1, MSYS Developer Tool Kit, including autoconf, automake, libtool, cvs and other tools
4、pthreads-w32-8-0-release.exe, The pthread library required by emulator.

Zlib, libpng, SDL, and the dependent directx-devel library do not need to be downloaded. zlib and libpng are already included in the Android Emulator source code package, SDL we can also use the binary provided in Android Prebuilt to provide a link later.

When installing MinGW, unless there is a special need, we can install the commonly used gcc core and g ++ compiler. If the network conditions are not good, you can open mingw. ini to find the file name, and then download it to the MinGW website using the download tool. To better manage the release of software packages, MinGW uses current, previous, and candidate to differentiate the combinations of software packages of different versions. Here I select current, gcc version 3.4.5.The installation path is random. Here it is assumed that it is c: \ mingw..

When installing MSYS, you will be asked if MinGW has been installed. If you select Y, you will be asked to enter the MinGW installation path. After entering it, you will soon be able to complete MSYS installation.Here we assume that the MSYS installation path is c: \ msys. Next, after installing the msysDTK-1.0.1, We can enter MSYS through the shortcut on the desktop. Here, we need to run the "ls/mingw" command to check whether MinGW is correctly mounted to the/mingw directory of MSYS. If you can see the bin, doc, include, and other directories, the mount is successful, otherwise, check the fstab file under etc in the MSYS installation directory. For the format, see fstab. sample. After the mounting is successful, try "gcc-v" and return the gcc version 3.4.5 and other characters. Then we can proceed to the next step.

Obtain the source code of Android Emulator and the SDL library in Prebuilt.

Refer to my previous articles on Git and Repo literacy-how to obtain the Android source code to obtain the source code of Android Emulator and the SDL library in Prebuilt, you can also download the snapshot versions of Emulator and Prebuilt from GitWeb.

After the download is complete, decompress the Emulator to the c: \ msys \ home \ <username currently logged in> directory. Prebuilt only requires the sdl directory under the Windows directory, also put it in the c: \ msys \ home \ <currently logged on user name> directory.

Here it is necessary to mention the Android Emulator build system, in the google androsource code package android-emulator-1.0_r2.tar.bz2, we can easily use the build-emulator.sh script to compile (may encounter some problems in the middle), we can see in this script, the script for building Emulator is a android-rebuild.sh that calls the android-configure.sh in the same directory to complete configure. Return to the External/qemu directory in Cupcake, we can see that the android-rebuild.sh and the android-configure.sh are both the same (at first I did think that only Emulator released in the form of source code package contains these scripts ), so we can compile Emulator when compiling the entire Android Cupcake code tree, and also use this parallel build system to build Emulator separately. From this point of view, there is no difference between building an Emulator, whether it is Cygwin or MinGW/MSYS.

Android Emulator compilation process

After completing the preceding steps, open MSYS, go to the Emulator (qemu) directory, and execute. /android-rebuild.sh-sdl-config =/home/<username currently logged in>/sdl/bin/sdl-config command, which will automatically call the android-configure.sh script for configure and then start compilation, -sdl-config specifies the path of the sdl library.

In the Pre-built.2, change the name of libpthreadGC2.a to libpthread. a to copy to the c: \ mingw \ lib directory, pthread. h to the c: \ mingw \ include directory.

In addition, the Android emulatorin Cupcake compilation is quite convenient. No errors such as "unsupported cpu" and "bad ELF header" were encountered before Android-emulator-1.0_r2.tar.bz2 compilation.

Test the generated Android Emulator

To test whether emulator.exe works normally, the simplest way is to copy it to the tools directory of the currently installed Android SDK, and add parameters-kernel,-ramdisk, and-system. Create an avdfile, for example, test_avdfile. Then run “emualtor.exe @ test_avd on the console. If anything is abnormal, add the-debug-all and-show-kernel parameters to debug the file.

Okay, there is a picture of the truth! In the title bar, "Build with MSYS/MINGW" is added by myself.
Leave a message to ask questions!

Compile a Windows-based Android Emulator (Cupcake)-William Hua Blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.