Qt 6.9.1 Android App Not Initialising and Not Obeying Safe Areas
-
I have a large Android app that works fine when built with Qt 6.7.2, but when built with Qt 6.9.1 the top level window extends into the system toolbar at the top of the screen and the navigation bar at the bottom.
A simple test application built with 6.9.1 works fine, and does not display this problem. It obeys the safe area margins.
A symptom of the fault, I suspect, is this error message put out when the app starts:
No implementation found for boolean org.qtproject.qt.android.QtNative.updateNativeActivity() (tried Java_org_qtproject_qt_android_QtNative_updateNativeActivity and Java_org_qtproject_qt_android_QtNative_updateNativeActivity__) - is the library loaded, e.g. System.loadLibrary?
This happens very early on, before the "I/QtCore : Start" debug message is put out.
My app has custom java Application and Activity, derived form the QtApplication and QtActivity. I have tried replacing those with the Qt classes, but that makes no difference.
Can anyone please suggest why the app is failing like this? Why is the Qt Android initialisation not working in this case?
-
I have a large Android app that works fine when built with Qt 6.7.2, but when built with Qt 6.9.1 the top level window extends into the system toolbar at the top of the screen and the navigation bar at the bottom.
A simple test application built with 6.9.1 works fine, and does not display this problem. It obeys the safe area margins.
A symptom of the fault, I suspect, is this error message put out when the app starts:
No implementation found for boolean org.qtproject.qt.android.QtNative.updateNativeActivity() (tried Java_org_qtproject_qt_android_QtNative_updateNativeActivity and Java_org_qtproject_qt_android_QtNative_updateNativeActivity__) - is the library loaded, e.g. System.loadLibrary?
This happens very early on, before the "I/QtCore : Start" debug message is put out.
My app has custom java Application and Activity, derived form the QtApplication and QtActivity. I have tried replacing those with the Qt classes, but that makes no difference.
Can anyone please suggest why the app is failing like this? Why is the Qt Android initialisation not working in this case?
The
WA_ContentsMarginsRespectsSafeArea
widget attribute is false on startup. Setting it true after the top-level widget has a layout makes no difference.
-
The
WA_ContentsMarginsRespectsSafeArea
widget attribute is false on startup. Setting it true after the top-level widget has a layout makes no difference.
Correction: a simple test app does show the symptoms - displaying outside the safe areas.
A full clean removal of the build directory and CMakeLists.txt.user and a fresh build and it is consistently showing the behaviour: the child widgets are drawn outside the safe areas.The simple test app is below.
It's confusing, because the same code, when rebuilt from scratch, can sometimes behave correctly. I have not been able to work out what the different results are caused by.
#pragma once #include <QWidget> class SafeAreaTestWidget : public QWidget { Q_OBJECT public: SafeAreaTestWidget(QWidget *parent = nullptr); ~SafeAreaTestWidget(); }; //////// #include "safeareatestwidget.hpp" #include <QVBoxLayout> #include <QLabel> #include <QLineEdit> #include <QTextEdit> #include <QTextBrowser> SafeAreaTestWidget::SafeAreaTestWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout * layout{ new QVBoxLayout{ this } }; QLabel * label{ new QLabel }; label->setText("Safe Area Test"); QLineEdit * lineEdit{ new QLineEdit }; QTextEdit * textEdit{ new QTextBrowser }; textEdit->setReadOnly(false); layout->addWidget(label); layout->addWidget(lineEdit); layout->addWidget(textEdit); setStyleSheet("QLabel { background-color: #880000; } * { background-color: #8888ff; }"); } SafeAreaTestWidget::~SafeAreaTestWidget() {} ////////// #include "safeareatestwidget.hpp" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); SafeAreaTestWidget w; w.show(); return a.exec(); }
-
Correction: a simple test app does show the symptoms - displaying outside the safe areas.
A full clean removal of the build directory and CMakeLists.txt.user and a fresh build and it is consistently showing the behaviour: the child widgets are drawn outside the safe areas.The simple test app is below.
It's confusing, because the same code, when rebuilt from scratch, can sometimes behave correctly. I have not been able to work out what the different results are caused by.
#pragma once #include <QWidget> class SafeAreaTestWidget : public QWidget { Q_OBJECT public: SafeAreaTestWidget(QWidget *parent = nullptr); ~SafeAreaTestWidget(); }; //////// #include "safeareatestwidget.hpp" #include <QVBoxLayout> #include <QLabel> #include <QLineEdit> #include <QTextEdit> #include <QTextBrowser> SafeAreaTestWidget::SafeAreaTestWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout * layout{ new QVBoxLayout{ this } }; QLabel * label{ new QLabel }; label->setText("Safe Area Test"); QLineEdit * lineEdit{ new QLineEdit }; QTextEdit * textEdit{ new QTextBrowser }; textEdit->setReadOnly(false); layout->addWidget(label); layout->addWidget(lineEdit); layout->addWidget(textEdit); setStyleSheet("QLabel { background-color: #880000; } * { background-color: #8888ff; }"); } SafeAreaTestWidget::~SafeAreaTestWidget() {} ////////// #include "safeareatestwidget.hpp" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); SafeAreaTestWidget w; w.show(); return a.exec(); }
It seems this is QTBUG-135808. Also the updateNativeActivity issue is benign and unrelated.
-
K KenAppleby 0 has marked this topic as solved