I’m recenly doing some research on mobile multi-platform game framework and since I’ve been playint with the cocos2d engie for a bit of time I think the cocos2d-x might be a great choice so planned to build the enviroment for both iphone and android under macos.
The whole process is far more tough than I ever thought(not to mention I am using a Hackintosh without internet connection). But, I finally get it done, so I’d like to write all the stuffs down and share it with all those who wanna do the same thing…
Here goes the process:
1.Install the leopard (I got a version of 10.6.5)
2.Install the XCode (I used the 3.2.5 since I don’t like the 4.0 for some reasons)
3.Install for iphone dev(I am using the latest version cocos2d-1.0.0-x-0.9.0)
You can get it here: http://cocos2d-x.googlecode.com/files/cocos2d-1.0.0-x-0.9.0.zip
3.1 Follow the tutorial here:
In one word, just run “sudo ./install-templates-xcode3.sh” and that’s all
4.Install for android dev (this is the toughest part)
4.1 Make sure you have JDK installed
You can input the “java -version” in your terminal to check
4.2 Make sure you have Ant installed (it’s better to use the version higher than 1.8.0)
You can input the “ant -version” in your terminal to check
4.3 Install Eclipse
I used the helios version (eclipse-jee-helios-SR1-macosx-cocoa) since it contains some nesscenary plugins (I tried to use the eclipse-SDK-3.7-macosx-cocoa at first but got some problems that’s hard to solve for me)
4.4 Install the ADT plugin
You can follow the instruction here:
http://developer.android.com/sdk/eclipse-adt.html
4.5 Install the Android SDK
If you got a internet connection than you can just follow this instruction:
http://developer.android.com/sdk/installing.html
But, if you got no internet connection and have to work offline just like me then that’s much more complex:
4.5.1 Download all the neccenary packages
Here is a good instruction to follow:
http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html
or
http://azerdark.wordpress.com/2011/04/21/android-sdk-offline-installation/
4.5.2 Unpack the packages to the right position
4.5.3 Create && run the emulator
4.6 Install the Andriod NDK (I am using the NDK r5)
You can get it here:
http://www.crystax.net/android/ndk.php
Follow the instruction here:
http://developer.android.com/sdk/ndk/index.html
4.7 Build && Run the Test demo
Follow the instruction here:
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_run_test_cases_on_android-ndk
4.8 Merging the Android project into the iPhone project
Follow the instruction here:
http://gameit.ro/2011/08/creating-an-iphone-and-android-cocos2d-x-hybrid-project/
And then the whole job is done
I’ll continue to share some stuffs during the learning of working with both cocos2d-x iPhone and android… so Stay tuned
Update:
My Hackintosh broke up recently and I re-installed the Mac OS and took a video along the way when I do all the stuffs above again.(My audio driver is still not working so I can not record the sound while recording…)
Here’s the video:
Video and Source code:
To Download Page…
PS:
This is the first time I made a video so there might be some flaw. (hope you don’t mind
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
If you feel all the stuffs in this site helped you a lot and you would buy me a beer ![]()
Or get a game I made


☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆





Pingback: How to port a simple project to win32,iPhone and Android | SuperSuRaccoon's World
very nice post, i certainly love this website, keep on it
Pingback: Demo Summary List | SuperSuRaccoon's World
Thanks for posting this, along with all the useful links. I found that on Mac OS X Lion with cocos2d-x-1.0.1-92, I ran into GLES compile errors if I tried to build a new project with the crystax NDKs. I’m not sure why, but I had to use the official Android r6b NDK with the Android r17 SDK.
The official Android r7 NDK gave me different compile errors (in CCGrabber.m), but I found the Android r6b NDK at this link: dl.google.com/android/ndk/android-ndk-r6b-darwin-x86.tar.bz2
With that, I was able to build a sample project, merge iOS and Android, and run in Eclipse. Thanks again for the roadmap.
Glad the post helped you and also thanks for the information I’am sure it’ll help someone too
我在最后一步运行android的cocos2d demo时,LogCat报如下错,大侠帮忙分析一下该怎么解决?12-28 21:50:57.963: E/AndroidRuntime(220): Caused by: java.lang.UnsatisfiedLinkError: Library cocos2d not found
该问题是我的COCOS2DX_ROOT的设置不对,现在已经解决了。但在mac android环境helloworld运行正常,没有出cocos2d的helloworld界面。郁闷中。
您说的这个COCOS2DX_ROOT正确的设置是怎样的 我也遇到这个问题了 不知道在哪弄
Awesome tutorial! Is there a way to add qnx project to this hybrid? Or is there a similar tutorial that takes into account blackberry as well?
Thanks!
Wow that was odd. I just wrote an extremely long comment but after
I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again.
Regardless, just wanted to say great blog!
Glad you love this blog
I’ll try my best to keep it on ~