The establishment of cocos2d-x2.2.3 and android platform environment

Source: Internet
Author: User

At first, I learned cocos2dx. Most people may be killed by complicated environment configuration processes. Especially when I build this project with the Android platform, it will drive people crazy, and each version will also have a lot of differences, I also referred to a lot to build in their own computer, only for reference, is based on the cocos2d-x2.2.3 version.

Preparation: 1. I just transplanted the cocos2d-x to the android platform, so the default for everyone has been set up the android platform (eclipse and android SDK has been configured, java environment is set up)

2. Download android DNK, I am using a android-ndk-r9d-windows-x86_64, I am a 64-bit System

3. Unzip the cocos2d-x and android ndk to the path you specified

Download the required software can try to transplant to the android platform, we take the Cocos2d-x directory comes with the project as an example, the general steps are as follows

 

Bytes -------------------------------------------------------------------------------------------------

1. Configure the android NDK runtime environment. Open Eclipse --> Window --> Preferences --> Android --> NDK and configure the installation path of your native NDK;


 

2. import the android dependency project of the cocos2d-x in your Eclipse (do not know if this statement is correct ), my approach is File-> New-> Other-> Android Project from Existing Code, import the cocos2d-x and android-related projects, my path is: D: \ cocos2d-x-2.2.3 \ cocos2dx \ platform \ android \ java, this project can be used as a dependency project for other android Projects

 

3. import the case Project. In Eclipse, File-> New-> Other, select Andriod Project from Existing Code, and set path D in the Root Directory of Import Projects: cocos2d-x-2.2 \ cocos2d-x-2.2 \ projects \ Helloworld \ proj. do not check copy project into workspace (not checked by default) for project import in the android directory. It is said that the path is very troublesome, so do not select it to avoid unnecessary troubles.

PS: Right-click the imported project-> Properties-> Android, and you will see at the bottom of the right. The Library part is the project imported in the previous step of dependency:

 

4. copy all the files in Resources in the sample project (D: \ cocos2d-x-2.2.3 \ samples \ Cpp \ HelloCpp) to the assets directory under the android project directory.

 

At this point, the sample project has been initially imported, but many errors will be reported because the compilation method has not been set.

Bytes -------------------------------------------------------------------------------------------------

5. Right-click the android project and choose Properties> Builders> New> Program,

In the Location under the Main tag, select Browse File Systerm... and select the ndk-build.cmd File under android NDK.

Working Directory, select Browse Workspace..., and select this project.

 

Under the Environment tag, click new,

Name: NDK_MODULE_PATH

Value: D:/cocos2d-x-2.2.3; D:/cocos2d-x-2.2.3/cocos2dx/platform/third_party/android/prebuilt (note your actual directory)

Select OK to confirm, return to the Builders interface, remove the check box before CDT Builder, and move the Builder you just created to the top. After all the configurations are complete, OK.

 

6. view android under the jni directory under the Android project. mk file, where LOCAL_SRC_FILES: You need to fill in all of your cocos2d-x project. cpp file (this self-built demo has been written. If you develop your own projects in the future, remember to fill it out), part:

 

7. it should be okay now. Try connecting to your mobile phone and try to use the test machine. The simulator is not easy to use. If there is no problem, the first compilation usually takes a long time, then you can see the running effect of this test demo.

Bytes -------------------------------------------------------------------------------------------------

 

Because I am also a small white cocos2d-x, a lot of things have no practice, are to view the experience shared by others, it is said that there may be encountered Program "bash" is not found in PATH error, google Baidu and stackoverflow haven't found any practical insights for a long time. They all say they need to install Cygwin. But isn't cygwin required for compiling with NDK? I have also encountered this error before, so I downloaded Cygwin. After a very long installation process, I configured the bin directory path under Cygwin to the system environment variable, and there was really no such error, if you encounter the same problem, I hope it will be helpful!

 

Well, it's time to port the dead man to the android environment for configuration. The rest is that you only need to use the C ++ code for the game code in, for me, the bigger difficulty is just getting started!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.