I'm trying to get Bluetooth working on Android x86 in virtualbox. I have tried both Virtualbox on Linux and Windows, with the latest android x86 iso, but the problem is the same: the bluetooth adapter of my thinkpad-laptop host (that is fully working) is not recognized.
- As an option, (to take advantage of USB 3.0 speeds) you can install the free VirtualBox Extension Pack. Once installed, start your virtual machine (be it Windows, Linux, or some other supported guest OS). Plug the required USB device in a USB port of your host computer. Now, head to Devices - USB, and click on ‘USB device to.
- VirtualBox network adapter settings allow you to change the MAC address of each virtual NIC, plug or unplug the virtual network cable, and select the network mode. Setting the network mode for a virtual network adapter is one of the most interesting and important parts of VirtualBox network settings.
Run Android on your PC
VirtualBox How To
The following are instructions on how to run Android-x86 inside VirtualBox.
Note: For optimal performance, make sure you have enabled either VT-x or AMD-V in your host operating system's BIOS.
Android-x86 versions tested against Virtualbox versions.
Date Tested | Virtualbox | Host OS | Android-x86 | Result |
---|---|---|---|---|
?? | 2.2.4 | Windows XP | ?? | Good |
?? | 3.0.2 | Fedora 11 | ?? | Good |
Nov. 2 2017 | 5.2.0 | Windows 10 | 6.0-r3 32/64 bit | Good |
Virtualbox Android Machine
Downloading
Download an ISO of Android-x86 from here.
Caution
If you are using Android-x86 for debugging purposes, some binaries (gdb for example) are built for 32-bit architectures and will not support debugging 64-bit binaries such as the Android app host. Download a 32-bit distribution instead.Create a new VM
If you have not already created a VirtualBox virtual machine for Android-x86 yet, do so as follows:
- Click the 'New' button, and name your new virtual machine however you like. Set Type to Linux, and Version to Linux 2.6 / 3.x / 4.x. Note that you should choose the appropriate bit type for the version of Android-x86 that you downloaded.
- Specify how much RAM will be allocated to your virtual machine when you run it. Android doesn't specify a bare-minimum requirement for memory, just keep in mind what apps you plan on running. 2GB (2048MB) is a good place to start, and you can change this later if you need to.
- Create a new Hard disk image which will act as your machine's storage. The recommended starting size of 8GB is enough. Click through the rest of the options for creating your Hard disk.
Settings
Virtualbox Android Host
Tested on VirtualBox 64-bit for Windows, version 5.2.0. Android-x86 version 6.0-r3, both 32-bit and 64-bit.
Select your machine, then click the Settings button and refer to the below recommended configuration to make sure your settings match.
- [System]Recommended: Processor(s) should be set above 1 if you have more than one virtual processor in your host system. Failure to do so means every single app (like Google Chrome) might crush if you try to use it.
- [Display]:
- Optional: Video Memory may be increased beyond the minimum selected automatically. The affects of this are unknown.
- Mandatory: Unless guest additions are installed[1], change the default VMSVGA to VBoxVGA.
- Optional: Enable 3D Acceleration may be checked. The Linux Guest Additions must (VirtualBox v6.1+) / may (VirtualBox v6.0 and below) need to be installed[2][1] to get any benefit from this. Failure to do so means you won't even be able to launch Android-X86 in the first place.[3]
- [Storage] Find the first 'Empty' item (this should have an icon of a CD). In the Attributes, click on the CD icon with a small down arrow, and pick 'Choose Optical Virtual Disk File...'. Specify the Android-x86 ISO that you downloaded.
- [Audio] Intel HD Audio seems to be natively supported in Android-x86.
- [Network] By default, your installation of Android-x86 will be able to automatically connect to the internet. If not, you can try to enable WiFi in Settings/Network & Internet, and connect to showing VirtWifi. If you do not want to connect to the internet in VirtualBox, uncheck Enable Network Adapter under the Adapter 1 tab.
Install
Click the green Start arrow to power-on your virtual machine. You'll be presented with a list of options. Use the arrow keys to pick which one you want, then press Enter once the one you want is selected.
- If you don't want to install Android-x86 yet and just want to test it, pick one of the Live CD options (except for Debug mode).
- Pick the Installation option if you want your system to be installed to the virtual hard drive.
Partition
When you are prompted to Choose a partition:
- If you upgrade Android-x86 from a previous version, just select the existing partition. Agree to overwrite it when prompted.
- If this is a new VM, choose to Create/Modify partitions. Use Bootable but not GPT! This will cause the GRUB installation to fail later.
Continue through the installation. You should install GRUB when it prompts you to. You may also leave /system as read and write when prompted.
Once the installation is complete, force close/shut down the virtual machine and remove the ISO from the virtual CD drive.
Finaly, start Android-x86. If it's a new machine, once loaded you can perform the Android setup to begin using your machine.
Advanced
Custom partitions, SDCard
When booting Android-x86, you may specify which partitions represent the data and sdcard. On the boot menu, select an entry you would like to boot from, press TAB, then add the following as it suits your needs:DATA=sda1 SDCARD=sda2 Press Enter to boot. These options specify user data (your setting, your uploaded applications, ...) go into /dev/sda1, and data saved in sdcard go into /dev/sda2.
If you build the ISO from source, you can add these options to bootable/newinstaller/boot/isolinux/isolinux.cfg.
Here is a note from David when using fdisk:
- Create a new virtual machine with a hard disk.
- Launch the Live ISO in Debug mode (I used android-x86-2.2-generic.iso) to get the commend prompt.
- 'fdisk /dev/sda', then type:
- 'n' (new partition)
- 'p' (primary partition)
- '1' (1st partition)
- '1' (first cylinder)
- 'xx' (choose the last cylinder, leaving room for a 2nd partition)
- 'w' (write the partition)
- Repeat #3, but call it partition 2, and use the remaining cylinders.
- 'mdev -s'
- 'mke2fs -j -L DATA /dev/sda1'
- 'mke2fs -j -L SDCARD /dev/sda2'
- Reboot ('reboot -f')
- At the boot menu, choose VESA, then hit TAB and type so that the end of the line reads: 'DATA=sda1 SDCARD=sda2'. (Only need for the generic target images, for VM target images, this is not needed)
- After booting (and of course disabling mouse integration via the machine menu), the SD card is read as unformatted, but you can format it by going to Settings > SD card & phone settings > Format SD Card, then Mount SD card.
- The SD card should now work!
DevTools application has a MediaScanner which (re)indexes your SD card for cases where you manually copied media over. This ensures that you see new images and/or music in the apps without having to reboot.
If you downloaded it from within android, the application asks the relevant service to index new files.
Playing music
This section describes two ways to upload music files into Android running on a vbox so you can play them by the Music app. Of course, you can save the files to the virtual disk mounted at /sdcard, as described above.
Upload files by adb
Adb is Android Debug Bridge, a tool to debug Android system. If you compile from source, it is located in out/host/linux-x86/bin/adb. Otherwise you can get it from Android SDK. Suppose the network of your vbox is OK, you can upload a file from your host by
ADBHOST=<ip of vbox> out/host/linux-x86/bin/adb push <a music file> /sdcard
For complex network settings of the VirtualBox VM, you should refer to Debug How To on how to connect adb to the VM.
Upload files by wget
You can also upload files by wget in the debug mode. In the debug mode shell, before entering Android,
# netcfg eth0 dhcp
# wget <url of a music file>
Virtualbox Android Adb
Then type exit to enter Android.Debug with adb
This section describes the way to debug Android with adb via network.
If we want to debug with adb via network, we should ensure the ip of vbox can be accessed by host machine. So we should change the Network Adapter type of vbox to Bridged Adapter. After starting the android-x86, we should follow the above Settings/[Network] section to ensure the network of android-x86 is enabled, and enable USB debugging in Settings/System/Developer Options. Then we can get the device ip from Settings/System/About tablet/IP address. For example, if we see the ip address is 192.168.0.116, then we can use following command to connect android-x86 in vbox from host machine.
Then you can use adb command to debug android-x86 such as get log, and dump system information.References
- ^ ab VirtualBox currently has no Guest Additions for Android.
- ^ VirtualBox v6.1.0 states: 'old style 3D support (with VBoxVGA) has been completely removed'
- ^ VirtualBox states: 'Note that you must install the Guest Additions on the guest VM to specify the VBoxSVGA or VMSVGA graphics controller.'
We are going to setup Android development environment with an Android Emulator.
If we install Android Studio (IDE) inside a Virtual Machine, the Android Emulator setup will fail. This is because Android Emulator is itself a Linux OS and cannot run inside another Virtual Machine. The way around this is to create two VMs in Virtual Box, one with development tools and other with Android OS. Then establish networking between the two VMs and connect Android development tools to Android instance in the other VM.
Let’s get started.
Create a Linux VM with Andriod development tools
1- Download preferred Linux OS image in .iso format. Ubuntu, one of the most popular Linux distributions, can be downloaded from here.
2- Create a new Virtual Machine in Virtual Box and set the desired values for RAM, number of CPUs, Secondary Storage etc.
3- Load the download iso file into VM’s optical drive.
Free Mac Os For Virtualbox
4- Start the VM and follow the installation wizard to completion. I have explained steps 2 – 4 in much more detail in another article (see section 1.2).
5- Download Android Studio and unzip it.
6- Start Android Studio by running ./android-studio/bin/studio.sh file. Go through the ‘Android Studio Setup Wizard’. This installs the latest Android SDK, Android SDK Platform-Tools, and Android SDK Build-Tools at~/Android/Sdk folder.
Install Android in a VM
1- Download Android x86 image in .iso format from https://www.android-x86.org/ . They have ported Android to x86 platform. The file I downloaded is android-x86_64-8.1-r1.iso
2- Create a new Virtual Machine in Virtual Box and set the desired values for RAM, number of CPUs, Secondary Storage etc.
3- Change the display option Graphics Controller to VBoxVGA and enable 3D animation for the VM.
4- Browse the download Android x86 iso file into VMs optical drive.
5- Start the VM and follow the installation wizard to completion. This also involves setting up the disk partition which can be a bit confusing. Find the details steps with screenshots here.
Establish networking between two VMs
I prefer NAT Network to establish the network between VMs. There are other ways of achieving this, see Virtual Networking Guide for more details.
1- In Virtual Box Preferences, create a new NAT Network. Note that this is in Virtual Box preferences, not in the settings of any VM.
2- Make sure both the VMs are turned off.
3- Change network of both VMs to NAT Network and select the name you just gave to new NAT Network.
Connect Android SDK with Android instance running in another VM
1- Start both VMs.
2- Find the IP Address of Android VM. You do that by searching for IP Address in settings.
3- Connect to Android from Android SDK using adb. Use the IP Address of Android VM and 5555 as port number.
~$ cd Android/Sdk/platform-tools/
~/Android/Sdk/platform-tools$ ./adb connect 10.0.2.4:5555
daemon not running; starting now at tcp:5037
daemon started successfully
connected to 10.0.2.4:5555