C ++ Firebase error in Android project

I am trying to add firebase C ++ sdk to my cocos2d-x 3.14 game. So far I have created Android.mk in the firebase_cpp_sdk directory:

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)

Then in my project in Android.mk I added:

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)

I can synchronize gradle and build a project. I can also

#include <firebase/app.h> 

in AppDelegate.cpp (or h) and it works great. Even Android studio can see all the firebase headers, and I can check them.

Now, in applicationDidFinishLaunching, I have added the following:

#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

There is also an alternative version via JNICALL from AppActivity.java (to convey the correct activity, as some say the solution above does not work):

#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

But my problem is: it doesn't even compile. Linker Error:

Error:(141) undefined reference to 'firebase::App::Create(firebase::AppOptions const&, _JNIEnv*, _jobject*)'

"" Android Studio, , . . .

? ?

+5
2

, :

, . :

LOCAL_STATIC_LIBRARIES += firebase-analytics firebase-prebuilt

.

github

0

Cocos , cmake ndk, frameworks/runtime-src/proj.android/gradle.properties PROP_BUILD_TYPE , , cmake ndk-build build.gradle frameworks/runtime-src/proj.android/app/build.gradle, ndk-build.

0

Source: https://habr.com/ru/post/1666484/


All Articles