2:请注意修改 android/build_native.sh文件, RESOURCE_ROOT修改为$GAME_ROOT/Resource, 我的0.9.1版本自动生成的为$GAME_ROOT/Resources
3: 修改android/jni/Android.mk文件如下(红色字体)
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ cocos2dx \ CocosDenshion/android \ lua/proj.android/jni \ )) subdirs += $(LOCAL_PATH)/pyramid/Android.mk include $(subdirs)
4:修改jni\helloworld\Android.mk中
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ $(LOCAL_PATH)/../../../../cocos2dx/platform \ $(LOCAL_PATH)/../../../../cocos2dx/include \ $(LOCAL_PATH)/../../../../cocos2dx/lua_support \ $(LOCAL_PATH)/../../../../CocosDenshion/include \ $(LOCAL_PATH)/../../../Classes \ $(LOCAL_PATH)/../../../../lua/lua \ $(LOCAL_PATH)/../../../../lua/tolua \ $(LOCAL_PATH)/../../../../lua/cocos2dx_support \ $(LOCAL_PATH)/../../../../lua/CocosDenshion_support
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \ -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ -lcocos2d \ -lcocosdenshion \ -llua
static { System.loadLibrary("cocos2d"); System.loadLibrary("cocosdenshion"); System.loadLibrary("lua"); System.loadLibrary("game"); }
8:需要注意一点就是Android.mk文件中
针对SRC和INC,其路径指定不一样,编译文件需要指定相对路径,而include文件需要指定绝对路径,比如:
PYRAMID_SRC_ROOT := ../../../Classes PYRAMID_INC_ROOT := $(LOCAL_PATH)/../../../Classes
9: 同时运行多个OS,比如windows、macos等,需要将build_native.sh文件转为unix格式
在cygwin下运行 dos2unix build_native.sh
10:小技巧
(1)可以通过uname判断是在什么os下,方便设置路径
if [ $(uname -s) = "Darwin" ]; then echo MacOs ANDROID_NDK_ROOT=/Volumes/work/tools/android/android-ndk-r6b-macosx else echo Cygwin ANDROID_NDK_ROOT=/cygdrive/f/tools/Android/android-ndk-r5c fi
windows下请下载: growl for windows
在build_native.sh最后加入:
if [ $(uname -s) = "Darwin" ]; then growlnotify -s -m :"ndk-build" $1" finish" else growlnotify /t:"ndk-build" $1" finish" fi
4:require 找不到需要的文件时, 防止弹出错误对话框
修改CCFileUtils_android.cpp文件 getFileData 函数,屏蔽 CCMessageBox(msg.c_str(), title.c_str()) 代码