FireBase and Qt6
-
@Joshika_Namani Please post the error message you get now
-
After modifying code:
static struct android_app* g_app_state = nullptr; // Get the activity. jobject GetActivity() { return g_app_state->activity->clazz; } JNIEnv* GetJniEnv() { JavaVM* vm = g_app_state->activity->vm; JNIEnv* env; jint result = vm->AttachCurrentThread(&env, nullptr); return result == JNI_OK ? env : nullptr; } void intialize(){ ::firebase::App* app; ::firebase::messaging::PollableListener listener; #if ANDROID app = ::firebase::App::Create(GetJniEnv(), GetActivity()); #else app = ::firebase::App::Create(); #endif
getting below erros:
../../main.cpp:52:11: error: no matching function for call to 'Create' app = ::firebase::App::Create(GetJniEnv(), GetActivity()); ^~~~~~~~~~~~~~~~~~~~~~~ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:538:15: note: candidate function not viable: no known conversion from 'JNIEnv *' (aka '_JNIEnv *') to 'const firebase::AppOptions' for 1st argument static App* Create(const AppOptions& options, const char* name); ^ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:497:15: note: candidate function not viable: requires single argument 'options', but 2 arguments were provided static App* Create(const AppOptions& options); ^ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:462:15: note: candidate function not viable: requires 0 arguments, but 2 were provided static App* Create(); ^ 1 error generated. make: *** [Makefile:466: arm64-v8a/main.o] Error 1 14:55:32: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
for previous code I got around 444 errors.
-
@Joshika_Namani Isn't the error message quite clear? There is no ::firebase::App::Create overload which takes two parameters of these types. The error message also tells you which 3 overloads are there, use one of them.
-
I tried
app = ::firebase::App::Create(app_options,"app");
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create(firebase::AppOptions const&, char const*)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:17:22: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) ^
for below code:
app = ::firebase::App::Create();
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create()' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:15:38: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
app = ::firebase::App::Create(app_options);
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create(firebase::AppOptions const&)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:18:04: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
-
@Joshika_Namani
This seems to me to indicate that now your code is correct, the compiler finds the necessary matching functions in an included header file, but the link line does not include whatever you are supposed to have as a (legitimate) library (at least for that function) for FireBase apps to link against? But this is not my area, I know no more, just a suggestion. -
@Joshika_Namani For the third time now:
I wrote before:
"f you get "undefined error" then you have to check whether these libraries are compatible with the architecture you're using (arm64-v8a)"And:
"post WHOLE build log if the build fails"Also: are there any other Firebase libraries besides the 3 you're linking?
-
@jsulm
right now, I'm not facing that issue and those libraries are compatible with my architecture(arm64-v8a) and got solved, My issue is with create function example :app = ::firebase::App::Create(app_options,"app");
-
@Joshika_Namani said in FireBase and Qt6:
My issue is with create function example :
So, you mean the linker error (undefined reference to `firebase::App::Create(firebase::AppOptions const&, char const*)), right?
That error clearly says that you have a problem with the shared libs.
I asked you to post the whole build log so we can see whether there are any warnings from linker about incompatible libraries - you still did not post the whole log.
I don't have anything to add... -
Below is my complete build log:
19:59:59: Initializing deployment to Android device/simulator 19:59:59: Deploying to d1d3484d 19:59:59: Running steps for project MessageApp_Version1... 19:59:59: Starting: "/home/joshikanamani/Qt/5.15.2/android/bin/qmake" /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/MessageApp_Version1.pro -spec android-clang CONFIG+=debug CONFIG+=qml_debug CONFIG+=force_debug_info CONFIG+=separate_debug_info ANDROID_ABIS=arm64-v8a 19:59:59: The process "/home/joshikanamani/Qt/5.15.2/android/bin/qmake" exited normally. 19:59:59: Starting: "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" -f /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/Makefile qmake_all make: Nothing to be done for 'qmake_all'. 19:59:59: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited normally. 19:59:59: Starting: "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" -j8 /home/joshikanamani/Android/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -c -target aarch64-linux-android21 -fno-limit-debug-info -fPIC -fstack-protector-strong -DANDROID -g -Wall -W -D_REENTRANT -fPIC -D__ANDROID__ -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_ANDROIDEXTRAS_LIB -DQT_CORE_LIB -I../../../MessageApp_Version1 -I. -I../../firebase_cpp_sdk/include -I/libs/ -I/home/joshikanamani/Android/ndk/21.3.6528147/sources/android/native_app_glue//sources/android/native_app_glue -I/home/joshikanamani/Qt/5.15.2/android/include -I/home/joshikanamani/Qt/5.15.2/android/include/QtQuick -I/home/joshikanamani/Qt/5.15.2/android/include/QtGui -I/home/joshikanamani/Qt/5.15.2/android/include/QtQmlModels -I/home/joshikanamani/Qt/5.15.2/android/include/QtQml -I/home/joshikanamani/Qt/5.15.2/android/include/QtNetwork -I/home/joshikanamani/Qt/5.15.2/android/include/QtAndroidExtras -I/home/joshikanamani/Qt/5.15.2/android/include/QtCore -Iarm64-v8a -Iandroid/app/build/intermediates/cmake/debug/obj/arm64-v8a/include -Iandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/include -I/home/joshikanamani/Qt/5.15.2/android/mkspecs/android-clang -o arm64-v8a/main.o ../../main.cpp ../../main.cpp:56:11: error: no matching function for call to 'Create' app = ::firebase::App::Create(::firebase::AppOptions(), GetJniEnv(), GetActivity()); ^~~~~~~~~~~~~~~~~~~~~~~ ../../firebase_cpp_sdk/include/firebase/app.h:538:15: note: candidate function not viable: requires 2 arguments, but 3 were provided static App* Create(const AppOptions& options, const char* name); ^ ../../firebase_cpp_sdk/include/firebase/app.h:497:15: note: candidate function not viable: requires single argument 'options', but 3 arguments were provided static App* Create(const AppOptions& options); ^ ../../firebase_cpp_sdk/include/firebase/app.h:462:15: note: candidate function not viable: requires 0 arguments, but 3 were provided static App* Create(); ^ 1 error generated. make: *** [Makefile:467: arm64-v8a/main.o] Error 1 20:00:00: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make" 20:00:00: Elapsed time: 00:01.
-
@Joshika_Namani said in FireBase and Qt6:
Below is my complete build log:
I do not know more than @jsulm and @JonB , but this log does not match with what you are actually doing. It still shows the "old" error where you tried to call a non-existing c'tor.
../../main.cpp:56:11: error: no matching function for call to 'Create' app = ::firebase::App::Create(::firebase::AppOptions(), GetJniEnv(), GetActivity());
So either you didn't saved your code file before building or you have multiple versions at the same time, or this is not the current error?!
I mean, you want to have working code... we can only give an advice. The fixing has to be done by you.
If you do the same - obviously not working - routines again and again... what do you expect? ;-)First, make sure that it links to Firebase correctly.
Then use the API the right way...
...in case of any further errors, check where they occur and see what you can do to fix it again. -
After doing some research, I was able to integrate QtFirebase into my Qt Android application, but I am encountering the RunTime issue below. I have tried various solutions, but the issue still persists.
I am encountering a runtime issue with my Android project using Qt and Firebase. Upon attempting to launch the app, it crashes with the following error:
`W Zygote : Unable to open libbeluga.so: dlopen failed: library "libbeluga.so" not found.
E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.croyance.messenger/com.croyance.messenger.Main}: java.lang.ClassNotFoundException: Didn't find class "com.croyance.messenger.Main" on path: DexPathList...The full logs can be found below. It seems that both the libbeluga.so native library and the Main activity are missing from the APK, which causes the application to fail at runtime. Additionally, there are several warnings related to Firebase initialization and some ANR (Application Not Responding) logs, which may be relevant.
`W Zygote : Unable to open libbeluga.so: dlopen failed: library "libbeluga.so" not found. I libc : SetHeapTaggingLevel: tag level set to 0 I yance.messenge: Late-enabling -Xcheck:jni I yance.messenge: Unquickening 21 vdex files! E yance.messenge: Unknown bits set in runtime_flags: 0x40000000 E RefClass: java.lang.reflect.InvocationTargetException I OneTrace: Mark active for pid=25278? true E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.croyance.messenger.Main" on path: DexPathList[[zip file "/data/app/~~AaqN-4a0auFr8HV_MJwQ3g==/com.croyance.messenger-itiNKy_Da7NGfGLvDCWqRw==/base.apk"],nativeLibraryDirectories=[/data/app/~~AaqN-4a0auFr8HV_MJwQ3g==/com.croyance.messenger-itiNKy_Da7NGfGLvDCWqRw==/lib/arm64...
I have correctly configured the AndroidManifest.xml file with the following activity declaration for Main:
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name=".Main" android:label="FireBaseQTVersion1" android:screenOrientation="unspecified" android:launchMode="singleTop"> </activity>
I have followed the setup guidelines for Android in the QtFirebase documentation, specifically as outlined in the Setup.
Environment:
Qt Version: 5.15.2 Firebase C++ SDK Version: 6.7.0 Android NDK Version: 21.3.6528147 Gradle Version: 5.6.4 Operating System: Linux