我正在尝试将firebase c ++ sdk添加到我的cocos2d-x 3.14游戏中.到目前为止,我在firebase_cpp_sdk目录中创建了Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := firebase-prebuilt LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/c++/libapp.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := firebase-analytics LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/c++/libanalytics.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY)
然后在Android.mk的项目中我添加了:
LOCAL_C_INCLUDES += /Users/piotr/Documents/pierdoly/firebase_cpp_sdk/include LOCAL_STATIC_LIBRARIES += firebase-prebuilt firebase-analytics $(call import-add-path, /Users/piotr/Documents/pierdoly/firebase_cpp_sdk)
我可以同步gradle和构建项目.我也可以
#include
在AppDelegate.cpp(或h)中,它工作正常.即使Android工作室也能看到所有的firebase标题,我可以检查它们.
现在,在applicationDidFinishLaunching中我添加了这个:
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) ::firebase::App* app = ::firebase::App::Create(::firebase::AppOptions()); #else ::firebase::App* firebaseApp = ::firebase::App::Create(::firebase::AppOptions(), cocos2d::JniHelper::getEnv(), cocos2d::JniHelper::getActivity()); #endif
还有来自AppActivity.java的JNICALL的替代版本(传递正确的活动,因为有人说上面的解决方案不起作用):
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) JNIEXPORT void JNICALL Java_org_cocos2dx_cpp_AppActivity_initFirebase(JNIEnv* env, jobject thiz) { ::firebase::App* app = ::firebase::App::Create(::firebase::AppOptions(), env, thiz); } #endif
但我的问题是:它甚至不会编译.有链接器错误:
Error:(141) undefined reference to 'firebase::App::Create(firebase::AppOptions const&, _JNIEnv*, _jobject*)'
我可以在Android Studio中清楚地"进入"此功能,并且我已经重新检查了两次我给的参数.他们很好.链接器对我大吼大叫.
我该如何修复链接器?我在这里错过了什么?