Você está na página 1de 8

Faster Android Emulator Alternative Using VirtualBox

Bobby Chan

The Android SDK Emulator can be quite slow on some systems, which makes Android app debugging especially painful for those who arent in possession of a physical device to test their Android apps on. Thankfully there is a solution by the guys at Android x86. The basic premise is to host the Android OS on VirtualBox. So far Android x64 only supports up to Android 2.2 Froyo, but they are currently working on porting over Android 2.3 Gingerbread. Lets skip the details and get started, as this is a fairly long tutorial.

Step 1: Install VirtualBox


1. Go to http://www.virtualbox.org, and click the downloads link on the side. Download the version for your system. Version 4.0.10 for Windows Version 4.0.10 for OS X 2. Install Virtualbox using recommended settings. Eh, its simple enough, as theres nothing to configure.

Step 2: Download the Android OS ISO


1. Go to http://www.android-x86.org/download, and download the generic ISO that matches your targeted Android version. (At the time this post was written, that file would be android-x862.2-generic.iso) Note: Click the view link under the file to download the ISO. Android 2.2 Froyo - android-x86-2.2-generic.iso Android 2.3 Gingerbread - android-x86.2.3-4th-test-110620.iso There are more Android OS ISO versions available at http://code.google.com/p/androbox/downloads/list

Step 3: Creating the Virtual Machine


1. Open up Oracle VM VirtualBox. 2. Create a new virtual host by clicking New. A dialog pops up, click next.

3. Name the virtual machine whatever you want, it doesnt really matter. The operating system is going to be Linux version 2.6. If you are running a 64-bit operating system, choose the 64-bit version of Linux.

4. In the next screen, give your virtual machine 512MB of RAM. 5. In the virtual hard disk screen, make sure Boot Hard Disk is checked and that Create new hard disk is selected. Hit next.

6. A new dialog will pop-up. When it prompts you for the hard disk storage type choose Fixedsize storage. Hit next. 7. Location can be left as the default. Set the size of the virtual hard disk to 2 GB (that is more than sufficient for the emulator). Then finish the dialog, and a virtual hard disk will be created. 8. Click finish again, and the virtual machine will be created.

Step 4: Adjusting Settings


1. Select the virtual machine you just created and change the settings.

2. Now to load the Android ISO disk file, go to Storage, under IDE Storage click Empty. Click the disk icon beside CD/DVD drive and Choose a virtual CD/DVD disk file

3. Now browse to the location of the generic ISO file you downloaded earlier, and open that file. We just mounted the ISO file to the virtual machine. 4. Next, we have to change the sound device. With the settings dialog still open, go to Audio. Set the audio controller to SoundBlaster 16. ICH AC97 will not work.

5. The next thing to set up is the network. Go to Network (obviously). Change the Attached To setting from NAT to Bridged Adapter.

6. If the name dropdown has more than one network adapter, select the one that connects to the internet, otherwise just leave it as the default. 7. Click OK to save the settings.

Step 5: Running the Emulator


1. Select your virtual device and click Start. Ignore the VirtualBox dialogs and just click OK.

2. Your mouse wont work at this point in the BIOS so just use your arrow keys. Select Live CD VESA Mode. Hit the return key.

3. The emulator will now load up. You should see the following screens.

4. Youll notice that the your mouse still wont show as you hover over the VirtualBox or emulator window. To fix this, go to the Machine dropdown menu at the top left corner and click Disable mouse integration.

5. Click anywhere on the screen and youll get a VirtualBox dialog prompting you to capture the mouse pointer. Click Capture.

6.

You can now move the mouse around, anywhere within the VirtualBox window. But what if I want to move it outside the window? Press the right control key and it will unlock the mouse. When you want the mouse back on the emulator, click anywhere on the screen and the repeat previous step. 7. (If you have never used an Android device, drag the lock out to unlock it.) You will then be brought to the home screen.

Step 6: Connecting Eclipse & ADB with the Emulator


1. Press Alt + F1 to bring up the console in the emulator (IE. VirtualBox window). (Alt + F7 To bring back the Android GUI) 2. Type netcfg, hit enter. Copy down the emulators IP address.

3. Assuming that you have ADB already installed and set up, open up the command prompt. Type in adb connect <emulators IP address>. 4. If everything went well, then it should say something similar to connected to <emulators IP address>:5555. If it is unable to connect, check your virtual machines network settings. Make sure its the correct adapter. If that doesnt fix it refer to the following link: http://www.androidx86.org/documents/debug-howto. If the command was not recognized, it means you havent set the path environment variable to your Android SDK folder location. Refer to http://www.cuteandroid.com/tips-for-androiddeveloper-android-sdk-tools-path-setting to set it up, and when complete retry step 3. 5. Close the command prompt. Now to connect Eclipse with the emulator, open up Eclipse (Im assuming the Android SDK and plugins are already installed.)

6. If you dont already have an Android project opened, create a new one that matches the version of your Android emulators version. Note: If you do have one opened, make sure the apps Android version matches the emulators version. 1. FileNewProjectAndroidAndroid Project 2. Give your test Android app a name. It could be something like AndroidTestProject 3. Leave the Contents section as-is. Under the Build Target section, check off the version of your Android emulator. 4. In the Properties section, give your app a package name. An example would be com.test.project. Package naming is really irrelevant for this tutorial, but if you care to learn more about it, feel free to look it up on Google. As for this tutorial, just make sure it starts with com. 5. Click Finish 7. Go to RunRun configurations 8. On the left-hand side, double click Android Application, and then under it, click New_configuration 9. Click on the Target tab. In the Deployment Target Selection Mode section, choose Manual.

10. Click Apply and close the window. 11. Now run and compile the project. 12. Depending on if you have any existing Android Virtual Devices, a dialog may pop-up prompting you to choose the device to install your test app to. Select your Android Emulator, and click OK.

13. It will compile and your app will be installed to your emulator. If you see your app, then youve done it!

SUCCESS!

Testing Your App Again


After youve set this all up, you dont need to do all of it over again. In order to set up the emulator after restarting the computer, you have to do the following: 1. Start up the emulator normally. (Open VirtualBox, start the virtual device, then choose Live CD VESA Mode.) 2. Get the emulators IP address (Alt+F1, then type in netcfg). 3. In the host computer, open up the command prompt and type in adb connect <Your emulators IP address>. You have to do this every time the computer restarts. 4. Run & compile your project in Eclipse and choose the Android Emulator device. 5. Youve once again installed your Android app to the emulator! Well there you go. It was one long setup, but definitely worth it if you dont own an Android device.

Keys
Enter Confirm Escape Back/return Alt + F1 Show console Alt + F7 Show Android GUI Arrows Moving navigation Right + Control Toggle mouse capture

Você também pode gostar