Details
-
Bug
-
Resolution: Incomplete
-
P4: Low
-
None
-
6.4.1
-
None
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'?