Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qgroundcontroll app error #47

Closed
Publicano opened this issue Apr 19, 2024 · 2 comments
Closed

qgroundcontroll app error #47

Publicano opened this issue Apr 19, 2024 · 2 comments

Comments

@Publicano
Copy link

Publicano commented Apr 19, 2024

Get an error when I implement it in the qgroundcontroll app

QAndroidBatteryState.cpp
QAndroidBatteryState.h

QT5.15.2

ERROR: fatal error: 'QJniObject' file not found
#include

@Publicano Publicano changed the title Problems implementation qgroundcontroll . Apr 19, 2024
@Publicano Publicano changed the title . qgroundcontroll app error Apr 19, 2024
@FalsinSoft
Copy link
Owner

Qt 5 are not supported anymore. There is a specific branch containing the latest version workings with version 5. You can try it if work for your app...

@NielsMayer
Copy link

NielsMayer commented Nov 2, 2024

@Publicano -- you can try something like I did in QAndroidCompat.h

// compatibility macros between Qt5 and Qt6 to accommodate the gratuitous name changes
// in the android interface and prevent code from becoming unreadable with ifdefs.

#pragma once
#include <QtGlobal> //define QT_VERSION, QT_VERSION_CHECK

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))            //Qt5

#include <QAndroidJniObject>
#include <QAndroidJniEnvironment>

#define TS_JNI_OBJECT                    QAndroidJniObject
#define TS_JNI_ENVIRONMENT               QAndroidJniEnvironment
#define TS_RUN_ON_ANDROID_MAIN_THREAD    QtAndroid::runOnAndroidThread
#define TS_HIDE_SPLASH_SCREEN            QtAndroid::hideSplashScreen
#define TS_GET_CONTEXT_JNI_OBJECT        QtAndroid::androidActivity
#define TS_GET_CONTEXT_JNI_JOBJECT       QtAndroid::androidActivity().object<jobject>

#else                                                   //Qt6

#include <QJniObject>
#include <QJniEnvironment>

#define TS_JNI_OBJECT                    QJniObject
#define TS_JNI_ENVIRONMENT               QJniEnvironment
#define TS_RUN_ON_ANDROID_MAIN_THREAD    QNativeInterface::QAndroidApplication::runOnAndroidMainThread
#define TS_HIDE_SPLASH_SCREEN            QNativeInterface::QAndroidApplication::hideSplashScreen
#define TS_GET_CONTEXT_JNI_OBJECT        QNativeInterface::QAndroidApplication::context

#if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0))            //worked for Qt6.2 through 6.6, broke in 6.7.0
#define TS_GET_CONTEXT_JNI_JOBJECT       QNativeInterface::QAndroidApplication::context
#else                                                   //workaround 6.7.0's "error: cannot pass object of non-trivial type 'QtJniTypes::Context' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs]"
#define TS_GET_CONTEXT_JNI_JOBJECT       QNativeInterface::QAndroidApplication::context().object<jobject>
#endif /* (QT_VERSION < QT_VERSION_CHECK(6, 7, 0)) */

#endif /* (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants