使用json时为android编译cocos2d-x项目时出错

时间:2014-11-28 21:57:55

标签: android json android-ndk cocos2d-x android.mk

我正在使用cocos2d-x版本3.3rc 在我的一些班级#include "cocos2d/external/json/writer.h" 当我想编译我的项目来制作android apk时,通过运行build_native.py脚本,它向我显示以下错误:

fatal error: cocos2d/external/json/writer.h: No such file or directory

但我使用以下语法将其文件包含在我的android.mk文件中:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
                    $(LOCAL_PATH)/../../cocos2d/external/json \

这是完整的android.mk文件:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)


LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
                    ../../Classes/AppDelegate.cpp \
                    ../../Classes/Database/CacheData.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
                    $(LOCAL_PATH)/../../cocos2d/external/json 

#LOCAL_STATIC_LIBRARIES := cocos2dx_static

LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += json_external_static


include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)

我该如何解决问题?

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。 在cocos2d-x版本3.3中,生成的默认 android.mk 文件已足够,并且已导入所有其他库。然后jni文件夹中的默认android.mk文件与其他.mk文件完全集成。我看到位于'cocos2s / external / json'的json文件夹中的文件是.h文件,它们与其他cocos2d文件和库之间没有依赖关系。 然后我只需将此文件夹复制到我的Classes文件夹并在本地包含它们。现在问题已解决:)