cocos2dx linux and android project in eclipse

 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. 


 







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值