[Graphic] Android-X86 + VirtualBox to build a high performance Android development environment

Source: Internet
Author: User
Tags line editor

I don't know how many Android developers have a problem with the tragic performance of Android virtual machines, anyway, my opinion is: That's too much speed!

Why are Android virtual machines much slower than iOS and WP7 's virtual machine? For the following reasons:

1. The Android simulator simulates the ARM architecture (Arm-eabi), while the target architecture for iOS and WP7 simulators is x86, and the App running in iOS emulator is compiled to x86. So the Android simulator needs to do some extra binary translation work.

2. The Android simulator is for QEMU's full system mode, which means that it needs to start the entire GUEST system and initialize various analog devices when it simulates. In contrast, IOS and WP7 simulators are just user-mode simulations.

3. The Android simulator also needs to run a Dalvik VM to perform the bytecodes of Android apps.

To sum up, slow one of the main reason is that the virtual machine is not run on the x86 but simulate arm, there is no way to get a x86 of Android?

The answer is of course ——— Open Source project android-x86, the Cow B open source project will be transplanted Android to the x86 platform, the system will not need to simulate the operation of ARM, so that Android can be installed directly on the PC or virtual machine running smoothly.

Everything's all right, just the east wind, I'll tell you what I use Android-x86 and VirtualBox to build the whole process of the handset development simulator

1. Download android-x86 System image file

First download Android-x86-2.2-generic.iso (click on the link directly), Mirror file about 82MB

2. Create a virtual machine on VirtualBox

Operating system Select Linux, version choose Linux 2.6

Memory recommended for 512MB

Hard drive default 8GB, because it is developed, 8GB more than sufficient

After the virtual machine is created, you will need to modify some of the configuration

The first is to adjust the network card, the connection method recommended to choose bridged adapter such a virtual machine in the local area network has an independent IP can facilitate access, and then control chip to select Pcnet-pci II, or android-x86 can not recognize the network card

If you want to have a sound, you need to set the control chip to Soundblaser 16 in the Sound Settings panel

Set the virtual machine's optical drive to the android-x86 ISO we just downloaded and start the virtual machine

The place of thought original article, declined to reprint

3. Install Android-x86 to virtual machine

After the virtual machine starts, you can see the following image

The first and second items are that you don't have to install the high, medium-dpi android-x86, and if you're interested you can run the x86 speed first.

We're going to install Android to the hard drive, select the last item and return

Installation–install android-x86 to Harddisk

Next we will enter the installation interface, the interface effect is as follows

We chose create/modify partitions to create the partition

First, we select New to create the partition

Select Primary to create the primary partition

The partition size takes the default size

Then we set the partition to boot (check bootable and return), this is the partition's flag will show boot, then we choose Write to write the changes to the hard disk (after you choose Write, you need to enter Yes to confirm)

After the partition is finished, select Quit to exit, and after exiting, we can see that the new partition we just allocated is recognized.

Press ENTER to select the partition, then ask what partition format to format the partition, the recommended choice of ext3

Select a good format after the system will confirm with you again, input Yes installation will start

Midway through the installation will ask you if you want to install grub, so be sure to select Yes because we need grub to customize startup Android

When you install GRUB, you will be asked if you want to install the/system directory as read/write mode (set to read-write can be more convenient for debug, but will take up more space and installation time), select Yes

After the carriage return, the installation will begin.

After the installation is complete, a menu pops up

Three options are

Running Android

Create a virtual SD card

Reboot

Because we are sure to use SD card, so here we create a virtual SD card

The size of the SD card will be asked to create, according to your needs, I set this is 128MB

The installer will begin initializing the SD card after the carriage return.

After the format is completed, you will be prompted to reboot, and then reboot after exiting the system disk in the virtual machine's CD drive, after reboot, you will be able to enter the Android system.

Note using the mouse in the Android system requires virtual box to prohibit automatic mouse exclusive, otherwise the mouse will not work in Android

Android-x86 Run screenshot:

The place of thought original article, declined to reprint

4. Custom Virtual Machine Resolution

We certainly need to test different resolutions when we develop, so how do we customize the resolution of the Android virtual machine?

First we need to start with the setup of Virtual box.

Open cmd, enter virtual box under the directory you created the VM, I created the virtual machine called android-x86, my account is administrator, the path on my Windows XP is

C:documents and Settingsadministratorvirtualbox vmsandroid-x86

Attention:

1. In different operating systems, the path will be different, according to the actual operating system to find, in principle, in your current user's personal folder

2.android-x86 is the name of the virtual machine I created, if yours is different from mine, please modify the name of the virtual machine you created

Here we need to use the command line tool provided by VirtualBox to add a custom resolution to your virtual machine, for example, I want to add a current popular mobile screen resolution 480x800, then we enter the command as follows

"C:Program FilesOracleVirtualBoxVBoxManage.exe" Setextradata "android-x86" "Customvideomode1″" 480x800x16 "

In the above order, the bold part is to be modified according to the situation on your own computer, the relevant explanation is as follows:

"C:Program FilesOracleVirtualBoxVBoxManage.exe"

is the full path to the Virtual box command-line tool VBoxManage.exe, depending on the actual path of the VirtualBox installed on your computer.

Note: If the path contains spaces, use double quotes to wrap the entire path

Android-x86

This is the name of the virtual machine.

480x800x16

This is a custom resolution, please change according to your own needs, the following 16 refers to 16-bit color, do not modify

If you want to add more resolution, please change the parameters and run the command more than once

After the modification, start the virtual machine, in the Android startup screen Select the option to press two times e key to edit the kernel boot parameters, add a parameter vga=ask, the specific process is as follows

Start Screen Press e key

Enter the new screen and press the E key once again

Then enter the kernel parameter edit state, add parameter Vga=ask

After editing, press ENTER to save the changes, then return to the previous page, at this point, press the B key to start

At this point the system will prompt you to enter the resolution selection interface, we press ENTER to continue

After entering the page, you can see all the system support resolution, then please look for the resolution you just set, in the following figure, you can find the resolution of the previous set of 480x800, note that the previous 16 code 360, if you want to start the virtual machine at this resolution, we enter 360 and then return to

When you enter, Android will start at the resolution you set, and the image below is a screenshot of the android-x86 virtual machine starting at 480x800 resolution.

Attention:

If you need the system to start with the resolution you specify, you need to perform the steps above each time the Android virtual machine starts to modify the kernel parameters to start Android

If you want Android to default to the resolution selection screen at startup or to start the virtual machine by default at the resolution you specify, you can refer to the following steps

1. Enter the android virtual machine and press ALT+F1 to enter the command line

2. Input Mkdir/data/fs

3. Mount the hard drive and use the following command

MOUNT-T hard disk format/dev/block/hard disk name/data/fs

Hard disk format for your virtual machine hard disk format, I am here is the ext3 hard disk name is your virtual machine

Hard disk name I this default is SDA1, the first SATA hard drive, Linx under the specific hard disk naming rules please Google

Mount-t ext3/dev/block/sda1/data/fs

To hang the hard drive on the/data/fs folder

4. Vi/data/fs/grub/menu.list Edit Launch Menu list (vi This command line editor how to use Google itself)

5. As it was just started, save after adding vga=ask at the end of the first kernel line

6. Restart the virtual machine, and you'll see that every time Android starts, it asks for resolution.

5. Remote debugging development on virtual machines using Eclipse ADT

Now that the virtual machine is configured, here's how to use Eclipse to run and debug the android application

When I set up the virtual machine in front of the virtual machine to set the network card bridged adapter, so that the virtual machine in the local area network equivalent to a stand-alone computer, you can set up an IP or its network card set to DHCP state to automatically obtain IP, I only explain the following in How to view the Android virtual machine IP in DHCP state:

Enter the android virtual machine, press ALT+F1 to enter the command, enter the NETCFG command to view the network status, the reference interface is as follows

Where eth0 is the current network card, followed by the IP address is the IP address obtained through DHCP

And then press ALT+F7 to return to the graphical interface after you figure it out.

At this time we open eclipse, into the Android development plug-in settings interface, select Ddms, check the use ADO host, and in the ADT host value of the virtual machine to fill in the IP address, the specific interface see the image below

Select OK to save, the Ddms interface on the device menu to choose to restart the ADB service, restart, you can see the DDMS connected to the virtual machine

You can then run and test your Android program on the virtual as usual, enjoy~

Finally, summarize the advantages and disadvantages of this environment:

Advantages:

1. High speed, compared to the Android SDK virtual machines, whether it is to start or run, the virtual machine quickly on a lot of, so you can run a smooth test of your Android applications, of course, can also comfortably experience the Android system on the computer:

2. Can simulate the environment of the tablet computer

Disadvantages:

1. Hardware support or tragedy, like phone calls, text messages, gravity sensors, GPS cameras, whatever. You still have to get a real machine debugging (but these things are not the simulator can do)

In addition to the Virtual Machine home page, return, shutdown, menu corresponding to the keyboard keys

Home key-> win key

Return key-> ESC

Hang machine key-> Alt+f4

Menu key-> Keyboard Menu key, general in the right win key and CTRL key between

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.