Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109549

qmake projects can no longer tag java classes with 'static_init_classes'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P4: Low
    • None
    • 6.4.1
    • Build tools: qmake
    • None
    • Android

    Description

      I am porting a qt5 android project to qt6. The project uses qmake, and builds a patched version of qtconnectivity and deploys it to the device.
      When I try to connect to a bluetooth device, the app crashes in QtBluetoothBroadcastReceiver.onReceive(...). 

      public void onReceive(Context context, Intent intent)
          {
              synchronized (qtContext) { // crashes here because qtContext is null
                  if (qtObject == 0)
                      return;
      
                  jniOnReceive(qtObject, context, intent);
              }
          } 
      

       

      In Qt5, AndroidManifest.xml supported the following metadata:

      <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> 

      which would result in an entry like this in libs.xml in the generated apk:

      <string name="static_init_classes">org.qtproject.qt.android.bluetooth.QtBluetoothBroadcastReceiver</string>

      'QtActivityDelegate::loadApplication(...)' would then call 'setContext' for modules that don't need/have setActivity, such as QtBluetoothBroadcastReceiver.java.

      After Qt6.2, this is not happening, as 'static_init_classes' metadata is no longer supported in AndroidManifest. (https://doc.qt.io/qt-6/android-manifest-file-configuration.html).

      How do I tag a java class like QtBluetoothBroadcastReceiver with 'static_init_classes'?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtbuildsystem Qt Build System Team
            daniel_mcinnes Daniel McInnes
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes