使用Eclipse NDK交叉编译:
1、...\cocos2d-x-2.2.2\cocos2d-x-2.2.2\projects\Myproject\proj.android\jni,打开Android.mk(可以使用EditPlus),修改以下内容:
(1)在(include $(BUILD_SHARED_LIBRARY)后面添加:
$(call import-add-path,D:/Android-kaifa/cocos2d-x-2.2.2/cocos2d-x-2.2.2)
$(call import-add-path,D:/Android-kaifa/cocos2d-x-2.2.2/cocos2d-x-2.2.2/cocos2dx/platform/third_party/android/prebuilt)
(2)在Android.mk中修改:把LOCAL_SRC_FILES这句替换成以下三
句:FILE_LIST := hellocpp/main.cpp FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
2、...\cocos2d-x-2.2.2\cocos2d-x-2.2.2\projects\Myproject\proj.android\src,下面添加org文件夹(来自...\cocos2d-x-2.2.2\cocos2d-x-2.2.2\samples\Cpp\TestCpp\proj.android\src)
3.设置横屏和竖屏:在pro.android目录下,有个AndroidMainfest.xml文件,打开,修改:(portrait(竖屏)、landscape(横屏))
android:screenOrientation="portrait"
4、打开Eclipse,
(1)file-》import项目-》Android-》Existing Android code into workspace->browse..--》选择自己的项目 (...\cocos2d-x-2.2.2\cocos2d-x-2.2.2\projects\Myproject\proj.android) -》finish
(2)右键项目-》属性(Properties)-》C/C++ Build下:修改
Build command :${NDK_ROOT}/ndk-build.cmd
5.开始编译:
点击菜单栏Project-》Build all开始编译编译结束后,点击你的项目Myproject右键,Run As->Android application打包结束,
apk包在目录Myproject\proj.android\bin下。
原文链接:https://www.f2er.com/cocos2dx/343882.html