您的位置:首页 > 运维架构 > Linux

cocos2dx linux and android project in eclipse

2011-09-03 11:47 417 查看
like what cocos2dx do, I wrote a script to build android project as well. but the difference is linux project will be built at the same time, and it apply standalone toolchain to compile directly in eclipse 3.7. Currently,
the script is named mycreate-android-project.sh in the base folder of cocos2dx. and before you read this, you had better read my first and second blog about cocos2dx for linux...
the step is like this for the first time to build the project.
1. build android ndk standalone environment, you reference my last blog here or get the guide from

http://www.srombauts.fr/android-ndk-r5b/docs/STANDALONE-TOOLCHAIN.html

2. As a project template Helloworld, you should set cocos2dx_loc first in preference->c/c++ build->build variables. cocos2dx_loc is the path to your cocos2dx base folder.



3. Change some macros in mycreate-android-project.sh to work in your environment.

NDK_ROOT="/home/laschweinski/android/android-ndk-r5"

the root of ndk

ANDROID_SDK_ROOT="/home/laschweinski/android/android-sdk-linux_86"

The root of android sdk

COCOS2DX_ROOT="/home/laschweinski/git/cocos2d-x"

the root of cocos2dx

then to build the project, simple command is like this:

laschweinski@laschweinski-laptop:~/Documents/workspace$ sh ~/git/cocos2d-x/mycreate-android-project.sh

(you could create the project wherever you want)

4. import projects, and test in eclipse 3.7

import the project where you run the command (in this case,~/Documents/workspace/[your
project name]/linux) in your eclipse

besides, the project has 4 target, Debug and Release is for linux, and AndroidDebug, AndroidRelease is for android, default compiled to be a shared lib for ndk. after
compiling the project, the libs will be copied to android/libs/armeabi. (due to a shell named postCompile.sh executed after compiled automatically, and I configure it in the post build in build step tab.)

the android project is in the android folder( ~/Documents/workspace/[your
project name]/android)

simply,new an android project and modifying the game lib (always
from "game" to
[your project name]) in An[your project name].java
are the only two things you need to do. However, Always, for the first time, the project will
have some errors with the resource R class.

therefore, please delete and import the project.

the two targets are run at the same time. just like the image below.



I believe this way could imporve the efficiency of the development more or less.

I am an non-native English speaker, if you have any confusion about this doc, please direct it without any hesitate.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐