This is a technical tutorial for build Cocos2D-HTML5 JSBinding for Android x86 devices. Cocos2d-html5 is an open-source web 2D game framework, released under MIT License. It is a HTML5 version of Cocos2d-x project. Its focus for Cocos2d-html5 development is around making Cocos2d cross platforms between browsers and native application. On top of the framework provided by Cocos2d-html5, games can be written in Javascript, using API that is COMPLETELY COMPATIBLE with that of Cocos2d-iPhone, Cocos2d-html5 also supports running game code in "Cocos2d Javascript binding" without or with little modification.

Before reading this tutorial, you need be experienced in developing NDK applications for Android devices, especially for Android X86 devices.

1）Prepare Building Environment

Eclipse, ADT, CDT, Android SDK, Android NDK are essential, at the same time, UDE is a good development tools provided by CMCC. It supports cross platform develop, debug, compile and will support game develop in near feature.

Cygwin is also needed while compile Cocos2D-HTML5 Jsbinding project. It’s provided by Redhat.

Unzip android-ndk-r8.zip to D:\Game\NDK, and then add this path to system environment or you can also add the path to Cygwin environment.

Add a new system environment and named it as NDK_ROOT and set its value to D:\Game\NDK\android-ndk-r8。

Hybrid application needs an interpreter to interpret JS codes. JavaScriptCore and SpiderMonkey are popular JS interpreters for developer.

Since JIT(Just-In-Time) can improve JavaScript performance, therefore, it’s very essential for HTML5 game developers to fix short point of performance issue.

Here is a topic shows why Cocos2d-HTML5 moved from JavaScriptCore to SpiderMonkey?

http://www.cocos2d-x.org/boards/20/topics/9696

My name is Rolando and I've been working on the cocos2d-x-javascript bindings for a while. We (Zynga) released as open source the branch old-js-bindings, that was using JavaScriptCore last week and right now we're openly working on a new, better, improved, faster, javascript bindings using SpiderMonkey.

Apparently everyone is using JavaScriptCore, but although that seems to be true, they are all infringing the LGPL license (actually Apple is infringing the License), so we searched for other JavaScript VMs and decided that SpiderMonkey was a good candidate.

https://developer.mozilla.org/en/docs/SpiderMonkeySpiderMonkey is Mozilla's JavaScript engine written in C/C++.

2）Copy file OR compile with Cygwin

You can choose either of them.

Cygwin is a very powerful tool to tuning C++ code and you could debug source code by gdb. Another method is building so by script build_native.sh. it’s more convenient than Android NDK which is co-worked by Cygwin. But this method is not powerful than Cygwin.

2.A）Copy file

An batch script is provided to save time. if you need to use this script to build other project, you only need to change the value of EngineHome and SamplesApp.

（Attached Pic MoonWar_01.jpg） Note: The picture is captured in Chinese version, it should be same in English version of Eclipse.

3.C） Add Related Library by Copying File.

If you don’t want 3.B solution, you could also add reference library by Copying file. Copying pre-build jar library to project folder as dependent library is another method, which is the same as 3.B step.

3.D） Check dependency library.

4）Customized your Builder

Right Click the project, Project -> Reference -> Builder -> New -> Program and then input the following information. Please make sure working directory is correct. If Cygwin is pre-installed and you have finished 2.B step successfully, you can skip this step 4 and go to step 5.

5.B）Build with Cygwin

If you find error during Package -> Run -> Run as -> Android, and it shows “No rule to make target: CCConfiguration.cpp”. It maybe occurred by file permission rejection or timeout during compiling. In this situation, you need to delete previous build library and rebuild them, repeat step 2.A and 5.A.

$ rm -Rf obj/*$ rm -Rf libs/*$ ./build_native.sh

6）If Error Occurs

If you find error during Package -> Run -> Run as -> Android, and it shows “Could not find *.apk”. It’s normally occurred by project settings error, It should be an application instead of a library, you need to change settings by following steps: