Build a high-performance Android development environment with Android-X86 and virtualbox

Source: Internet
Author: User
Tags line editor


I don't know how many Android Developers have opinions on the tragic performance of the android Virtual Machine. My opinion is: the speed is too bad!



Why are Android virtual machines much slower than iOS and WP7 virtual machines? The reason is as follows:



1. the android Simulator simulates the ARM architecture (ARM-Eabi), while the target architecture of iOS and WP7 simulators is x86, in addition, the app running in the IOS simulator is also compiled into x86. In this way, the android simulator requires some additional binary translation work.
2. the android simulator uses the full system mode of qemu, that is, it needs to start the entire guest system during simulation and initialize various analog devices. On the contrary, the simulators for iOS and WP7 are only user-mode simulations.
3. In the android simulator, you also need to run a Dalvik VM to execute the bytecodes of the android application.



To sum up, one of the main reasons for the slow speed is that the virtual machine is not running on x86 but simulating arm. Is there a way to get an x86 android?



The answer is, of course, there are open-source projects.Android-x86This open-source project of niub transplanted android to the X86 platform, and the system does not need to be simulated as arm when running, so that android can be directly installed on a PC or virtual machine and run smoothly.
Everything is ready, only owe Dongfeng, next I will talk about the whole process of using Android-X86 and virtualbox to build a mobile phone Development Simulator



1. Download a Android-x86 System Image File



First downloadAndroid-x86-2.2-generic.iso(Click the link directly). The image file size is about 82 MB.



2. Create a virtual machine on virtualbox



Select Linux as the operating system and Linux 2.6 as the version






The recommended memory size is 512 MB.






 



The default hard disk is 8 GB, because it is used for development, more than 8 GB memory



After the virtual machine is created, you need to modify some configurations.



The first is to adjust the network card, the connection mode is recommended to select bridged adapter so that the virtual machine in the LAN has an independent IP address for easy access, and then the control chip to choose pcnet-pci ii, otherwise the Android-x86 cannot recognize the network card



 






If you want to have a sound, you need to set the control chip to soundblaser 16 on the sound settings panel.



 






Set the virtual machine drive to the Android-x86 we just downloaded ISO, start the Virtual Machine



 



 






Place of thoughtOriginalArticle, Declined to reprint



3. Install Android-x86 to Virtual Machine



After the virtual machine is started, you can see the following picture



 






The first and second projects are so that you do not have to install experience high, medium DPI Android-x86, if you are interested, you can first run experience x86 speed



We want to install android to the hard disk. Select the last item and press Enter.
Installation-install Android-x86 to harddisk



Next, we will go to the installation interface. The interface effect is as follows:



 






Select create/modify partitions to create a partition.



First, select new to create a new partition.






Select primary to create the primary Partition






Use the default partition size.






Then we set the partition to boot (select bootable and press Enter). This is the partition flag that will display boot, then we select write to write the modification to the hard disk (after selecting write, we also need to enter yes to confirm)




After the partition is complete, select Quit to exit. After exiting, we can see that the newly allocated partition is identified.






 



Press enter to select the partition. In this case, you will be asked what partition format is used to format the partition. We recommend that you select ext3.






 



After the format is selected, the system will confirm with you again. Enter yes to start installation.



During the installation process, you will be asked if you want to install grub. Select Yes here, because grub is required to start Android later.






When installing grub, you will be asked if you want to install the/system directory in read/write mode (set it to debug, which is easier to read and write, but takes more space and installation time). Select Yes






 



After you press enter, the installation will start.






After the installation is complete, a menu is displayed.



The three options are



Run Android
Create a virtual SD card
Restart






 



Because SD cards are certainly used for development, we create a virtual SD card here.



You will be asked about the size of the SD card when you create it. You can set it according to your needs. Here I set it to 128 MB.






 



Press enter to installProgramThe SD card will be initialized.



After the format is complete, you will be prompted to restart. After exiting the system disk in the VM optical drive, restart the system disk and then enter the Android system.



Note: when using the mouse in the Android system, you need to set virtual box to prohibit automatic mouse exclusive. Otherwise, the mouse cannot be used normally in Android.






Android-x86 run:






 



Place of thoughtOriginal article, declined to reprint



4. Custom Virtual Machine resolution



We certainly need to test different resolutions during development. How can we customize the resolutions of Android virtual machines?



First, we need to start with the virtual box settings



Open CMD and enter the Virtual Machine directory you created under virtual box. The virtual machine I created is called Android-x86, my account is administrator, and the path on my Windows XP is



C: \ Documents and Settings \ Administrator \ virtualbox VMS \ Android-x86



Note:



1. The path varies depending on the operating system.In your current user's personal folder



2.Android-x86 is the name of the virtual machine I created, if you are different from me, Please modify the name of the virtual machine created for you



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 popular mobile phone screen resolution of 480x800, the command we entered is as follows:



"C: \ Program Files \ oracle \ virtualbox \ vboxmanage.exe"Setextradata"Android-x86"" Customvideomode1 ""480x800x16"



In the above command, the bold part is to be modified according to the situation on your computer. The related explanation is as follows:



"C: \ Program Files \ oracle \ virtualbox \ vboxmanage.exe"



Is the complete path of the virtual boxcommand line tool vboxmanage.exe, Please modify according to the actual path of virtualbox installed on your computer



Note: If the path contains spaces, use double quotation marks to enclose the entire path.



Android-x86



This is the name of the VM.



480x800x16



This is a custom resolution. Please modify the resolution based on your needs. The following 16 colors indicate 16 bits. do not modify the resolution.



If you want to increase the resolution, modify the parameters and run the command multiple times.






 



After the modification, start the VM. select the option in the android boot screen and press the e key twice to edit the kernel startup parameter. Add the VGA = Ask parameter. The specific process is as follows:
Press E on the startup Screen






 



Press the e key again after entering the new screen.






Enter the Kernel Parameter editing status, and add the VGA = Ask parameter.






After editing, press enter to save the Modification result. The Modification result will return to the previous page. Press B to start the modification.



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






After entering the page, you can see all the resolutions supported by the system. Please look for the resolution you just set. In, you can find the previously set X resolution, pay attention to the hexadecimal format above it.Code If you want to start the VM at this resolution, enter  and press Enter.






Press enter, Android will start according to the resolution you set, is to 480x800 resolution to start the Android-x86 Virtual Machine






Note:



If you want the system to start at the specified resolution, you needRun the operation above to modify the kernel parameters to start android



If you want android to go to the resolution selection screen by default at startup or start the virtual machine with the resolution you specified by default, follow these 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 disk by running the following command:



Mount-t hard disk format/dev/block/Hard Disk name/data/fs



The hard disk format is the format of your virtual machine hard disk. Here, the ext3 hard disk name is yours.



Hard Disk name. This is sda1 by default, indicating the first SATA hard disk. For specific hard disk naming rules under Linx, Google



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



Mount the hard disk to the/data/fs folder



4. VI/data/fs/GRUB/menu. List edit the Startup Menu list. (For details about how to use the VI command line editor, Google it)



5. Add VGA = ask at the end of the line of the first kernel, and save
6. Restart the Virtual Machine. At this time, you will find that every time Android is started, you will ask about the resolution.



5. Use eclipse ADT for remote debugging and development on virtual machines



Now that the virtual machine has been configured, the following describes how to use eclipse to run and debug Android applications on it.



When I set the VM, I set the NIC of the VM to the bridged adapter. In this way, the VM is equivalent to an independent computer in the LAN, you can set an IP address for it or set the NIC to DHCP to automatically obtain the IP address. Here I will only explain how to view the IP address of the android virtual machine in the DHCP status:



Enter the android virtual machine, press Alt + F1 to enter the command, enterNetcfgCommand to view the network status, refer to the interface below






Eth0 indicates the current Nic, And the IP address following it is the IP address obtained through DHCP.



Then press Alt + F7 to return to the graphic interface.



In this case, open eclipse, go to the android development plug-in setting interface, select ddms, select use ADO host, and fill in the Virtual Machine IP address in the ADT host value column. For details, see






 



Click OK to save the settings. On the device menu on the ddms interface, restart the ADB service. After the restart, you can see that the ddms is connected to the VM.






 



Then you can run and test your android program on the virtual machine as usual, enjoy ~



Finally, we will summarize the advantages and disadvantages of this environment:



Advantages:
1. high speed. Compared with the android SDK virtual machine, whether started or running, this virtual machine is much faster, allowing you to smoothly run and test your Android Application. Of course, you can also experience the Android system on your computer comfortably :)
2. Simulate the tablet Environment



Disadvantages:



1. hardware support is still tragic, such as phone calls, text messages, gravity sensing, and GPS cameras. You still have to debug a real machine (but these things are not something the simulator can do)



In addition, you can add the keyboard buttons corresponding to the home page, return, shutdown, and menu of the VM.
Home Key-> win key
Return key-> ESC key
Hanging key-> Alt + F4
Menu key-> keyboard menu key, usually in the middle of the right win key and ctrl key


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.