Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 6.9.1 Android App Not Initialising and Not Obeying Safe Areas
Forum Updated to NodeBB v4.3 + New Features

Qt 6.9.1 Android App Not Initialising and Not Obeying Safe Areas

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 1 Posters 142 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • KenAppleby 0K Offline
    KenAppleby 0K Offline
    KenAppleby 0
    wrote last edited by
    #1

    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?

    KenAppleby 0K 1 Reply Last reply
    0
    • KenAppleby 0K KenAppleby 0

      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?

      KenAppleby 0K Offline
      KenAppleby 0K Offline
      KenAppleby 0
      wrote last edited by
      #2

      The

      WA_ContentsMarginsRespectsSafeArea
      

      widget attribute is false on startup. Setting it true after the top-level widget has a layout makes no difference.

      KenAppleby 0K 1 Reply Last reply
      0
      • KenAppleby 0K KenAppleby 0

        The

        WA_ContentsMarginsRespectsSafeArea
        

        widget attribute is false on startup. Setting it true after the top-level widget has a layout makes no difference.

        KenAppleby 0K Offline
        KenAppleby 0K Offline
        KenAppleby 0
        wrote last edited by
        #3

        @KenAppleby-0

        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();
        }
        
        KenAppleby 0K 1 Reply Last reply
        0
        • KenAppleby 0K KenAppleby 0

          @KenAppleby-0

          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();
          }
          
          KenAppleby 0K Offline
          KenAppleby 0K Offline
          KenAppleby 0
          wrote last edited by
          #4

          It seems this is QTBUG-135808. Also the updateNativeActivity issue is benign and unrelated.

          1 Reply Last reply
          0
          • KenAppleby 0K KenAppleby 0 has marked this topic as solved

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved