build.xml:找不到:build_common.xml

build.xml: Cannot find: build_common.xml

我正在尝试将 Facebook 插件集成到全新的 cocos-js 3.7 项目中。 以下步骤来自:http://cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/facebook-sdk-on-android/en 以及我现有的 3.5 项目,这个插件运行良好。

编译时出现此错误:

BUILD FAILED
/Applications/adt-bundle-mac-x86_64-20130729/sdk/tools/ant/build.xml:470: The following error occurred while executing this line:
/pp/src/shared_js/cocos/3.7/frameworks/cocos2d-x/plugin/protocols/proj.android/build.xml:90: Cannot find /pp/src/shared_js/cocos/3.7/frameworks/cocos2d-x/plugin/protocols/proj.android/${plugin.dir}/tools/android/build_common.xml imported from /pp/src/shared_js/cocos/3.7/frameworks/cocos2d-x/plugin/protocols/proj.android/build.xml

cocos2d-x/plugin/protocols/proj.android/build.xml 中的最后一行有:

<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />

导致问题的原因。

在哪里定义 ant 导入的搜索路径?

我的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := cocos2djs_shared

LOCAL_MODULE_FILENAME := libcocos2djs

LOCAL_SRC_FILES := hellojavascript/main.cpp \
                   ../../Classes/AppDelegate.cpp 

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

##############################################################################################################
# Library lists
##############################################################################################################

# <Pp> this prevents bugs with += and :=
#
LOCAL_STATIC_LIBRARIES :=
LOCAL_WHOLE_STATIC_LIBRARIES :=

# cocos 3.7
#
LOCAL_STATIC_LIBRARIES += cocos2d_js_static

# plugin: ALL (JS & C++)
# plugin: FB
#
# <REF> /pp/dev-cpp/libs/cocos2d-js-v3.5/samples/js-tests/project/proj.android/jni/Android.mk
#
LOCAL_STATIC_LIBRARIES += jsb_pluginx_static


# plugin: ALL (JS & C++)
# plugin: FB
#
LOCAL_WHOLE_STATIC_LIBRARIES += PluginProtocolStatic

##############################################################################################################
# Flags, etc.
##############################################################################################################


# cocos 3.7
#
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT

# cocos 3.7
#
include $(BUILD_SHARED_LIBRARY)


##############################################################################################################
# Module search paths
##############################################################################################################


# Pp: believed to be required by plugins and also some other staff...
#
$(call import-add-path,$(LOCAL_PATH)/../../../../frameworks/cocos2d-x/plugin/publish)
$(call import-add-path,$(LOCAL_PATH)/../../../../frameworks/cocos2d-x/external)
$(call import-add-path,$(LOCAL_PATH)/../../../../frameworks/cocos2d-x/cocos)

# Pp (after upgrade to cocos 3.7)
#
$(call import-add-path,$(LOCAL_PATH)/../../../../frameworks)

# Soomla (also generic)
#
$(call import-add-path,$(LOCAL_PATH)/../../../../frameworks/cocos2d-x)

##############################################################################################################
# Import Modules
##############################################################################################################

# cocos 3.7
#
$(call import-module, scripting/js-bindings/proj.android)


# plugin: ALL (JS)
# plugin: FB
#
# <REF> /pp/dev-cpp/libs/cocos2d-js-v3.5/samples/js-tests/project/proj.android/jni/Android.mk
#
#
$(call import-module,cocos2d-x/plugin/jsbindings)


# plugin: ALL (C++)
# plugin: FB
#
# <REF> /pp/src/shared_js/cocos/3.5/frameworks/js-bindings/cocos2d-x/plugin/samples/HelloPlugins/proj.android/jni/Android.mk
#
$(call import-module,plugin/protocols/proj.android/jni)

通过以下步骤解决。这可能不是正确的方法,因为它涉及手动修改 local.properties 但它有效。

1.漏洞

/Applications/adt-bundle-mac-x86_64-20130729/sdk/tools/ant/build.xml:470: The following error occurred while executing this line:
/pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/protocols/proj.android/build.xml:90: Cannot find /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/protocols/proj.android/${plugin.dir}/tools/android/build_common.xml imported from /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/protocols/proj.android/build.xml

修复:

    $ vi /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/protocols/proj.android/local.properties

    # add this line
    plugin.dir=../..

2。漏洞

/Applications/adt-bundle-mac-x86_64-20130729/sdk/tools/ant/build.xml:470: The following error occurred while executing this line:
/pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/plugins/facebook/proj.android/build.xml:90: Cannot find /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/plugins/facebook/proj.android/${plugin.dir}/tools/android/build_common.xml imported from /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/plugins/facebook/proj.android/build.xml

修正

    $ vi /pp/src/shared_js/cocos/3.8/frameworks/cocos2d-x/plugin/plugins/facebook/proj.android/local.properties

    # add this line
    plugin.dir=../../..