最近在弄一个cocos2dx项目时,编译android版本遇到一些问题,特总结如下,已帮助其他朋友:
本人开发环境如下:
cocos2dx version:cocos2dx3.2
os:win7
1、如果你只是用到了基本的cocos2dx的功能,基本上不用看本教程,直接安装官方的指导课程即可。
http://cn.cocos2d-x.org/article/index?type=cocos2d-x&url=/doc/cocos-docs-master/manual/framework/native/v3/getting-started/setting-up-development-environments-on-windows7-with-eclipse/zh.md
2、如果你的项目里用到了cocostudio,或者其他方面的库支持的话,会遇到undifined references 类似的错误,分2种情况:
1> 未定义的是cocos2dx引擎中的类或者变量,此时需要在your project/cocos2d/cocos/android.mk
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/. \
$(LOCAL_PATH)/platform/android \
$(LOCAL_PATH)/../external/tinyxml2 \
$(LOCAL_PATH)/../external/unzip \
$(LOCAL_PATH)/../external/chipmunk/include/chipmunk \
$(LOCAL_PATH)/../external/xxhash \
$(LOCAL_PATH)/../external/nslog \
$(LOCAL_PATH)/../external \
$(LOCAL_PATH)/editor-support
2> 未定义的自己实现的类,此时需要在your project/proj.android/jni/android.mk
LOCAL_SRC_FILES :=
在这里添加自己实现的类
# LOCAL_WHOLE_STATIC_LIBRARIES += Box2d_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
# LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
在自己项目里引用的其他库,把前面的#注释去掉,以引用该库
# $(call import-module,Box2D)
# $(call import-module,editor-support/cocosbuilder)
# $(call import-module,editor-support/spine)
$(call import-module,editor-support/cocostudio)
# $(call import-module,network)
# $(call import-module,extensions)
与上面配合处理
3、 在eclipse里,AppActivity.java会报错,那是因为cocos2dx java src没有导入
修改java build path
yourproject\cocos2d\cocos\2d\platform\android\java\src改为
yourproject\cocos2d\cocos\platform\android\java\src