Cocos2D-X develop for Android on Virtual Box
Android can be installed as a virtual machine, but cocos2d-x needs OpenGL support.
This is where AndroidVM comes in.You can download it at AndroidVM.For this setup I used a linux environment.
Setting it on other platforms would be almost the same.
- VirtualBox – I guess you already know what this one is since you are here.
- AndroidVM – An Android virtual machine
- AndroidVMPlayer – This is the emulator like device we will be using
- Android SDK – we will use SDK platform-tools(adb) for connecting to the Virtual machine.
- Android NDK – compile your cocos2dx project
- Download and install VirtualBox.
- Download AndroidVM (Choose one according to your OS)
- Download AndroidVMPlayer and extract it somewhere you can easily find
- Import AndroidVM to VirtualBox (double click the downloaded VM or import through menu)
- You can close the virtualbox now
- In your PC now, open a terminal and cd to the folder you extracted AndroidVMPlayer and execute ./AndroidVMPlayer.sh
- It will setup the virtual machine and hardware acceleration for you, when the virtual device starts you will see an IP on the window title, this IP will be used to connect the adb with AndroidVM
Connecting the adb
- Goto your android-sdk/platform-tools
- Execute ./adb connect IP (of the virtual machine, the one you noted ex:192.168.56.101)
- If connected the next time you try launching your Android app from Eclipse you can choose AndroidVM as a device.
Usage and Notes:
- You can start AndroidVM through AndroidVMPlayer.sh so no need to launch virtual box , but still need to connect with adb
- Using api 2.3 – be sure to add APP_ABI := x86 to your Application.mk or you will get UnsatisfiedLinkError
- Using api 4.0 – APP_ABI := armeabi
- Using api 4.2 – APP_ABI := armeabi-v7a
- AndroidVMPlayer may need 1-2 seconds to refresh when switched to another window and back (same as the emulator)
Enjoy fast openGL supported virtual device 🙂