A/: (null):0 ((null)): QWidget: Must construct a QApplication before a QWidget
-
Hello Everyone Thank for your attention and help!
my requirement is want to Invoke *.so (Dynamic libraries encapsulated via Qt5.9.4 and has containing UI display code,, eg: QWidget) through JNI in Android Studio Chipmunk。
But there show a mistake in the simulator(android x86):2022-05-12 16:09:39.101 13575-13575/com.example.ndkbuilddemo1 A/: (null):0 ((null)): QWidget: Must construct a QApplication before a QWidget
--------- beginning of crash
2022-05-12 16:09:39.101 13575-13575/com.example.ndkbuilddemo1 A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 13575 (e.ndkbuilddemo1), pid 13575 (e.ndkbuilddemo1)
-
@tommy704704 said in A/: (null):0 ((null)): QWidget: Must construct a QApplication before a QWidget:
2022-05-12 16:09:39.101 13575-13575/com.example.ndkbuilddemo1 A/: (null):0 ((null)): QWidget: Must construct a QApplication before a QWidget
I know nothing about Android/JNI, but as the message states you must never try to create any
QWidget
before you have made the call to create aQApplication
. Do you try to do so, or does your loaded*.so
file have or create aQWidget
anywhere beforeQApplication
has been created? -
I use the *.so encapsulated by the Qt, which has no qapplication and main function‘s entries
-
@tommy704704
As I said, although I know nothing about Android/JNI the error message tells you that in Qt noQWidget
can be created until after aQApplication
has been constructed. What you do/have to do about that is up to you/unknown to me. -
Because I want to reuse a ui code I wrote with qt in Android, I encapsulate the ui code into a so library. Then call and display in android studio.
If My * .so does not use UI code(eg:QWidget), then JNI calls *.so and it works fine.
I'm not sure if JNI can call the UI code of the so library encapsulated by Qt?
-
*The above problem has been solved but the app will still crash, this is the output information. So I'm not sure if android can call .so library which contains qt ui code(eg:QWidget)
2022-05-12 17:19:31.694 14385-14385/? I/e.ndkbuilddemo: Late-enabling -Xcheck:jni
2022-05-12 17:19:31.707 14385-14385/? E/e.ndkbuilddemo: Unknown bits set in runtime_flags: 0x8000
2022-05-12 17:19:31.708 14385-14385/? W/e.ndkbuilddemo: Unexpected CPU variant for X86 using defaults: x86
2022-05-12 17:19:32.064 14385-14420/com.example.ndkbuilddemo1 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2022-05-12 17:19:32.065 14385-14420/com.example.ndkbuilddemo1 W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2022-05-12 17:19:32.071 14385-14420/com.example.ndkbuilddemo1 D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2022-05-12 17:19:32.072 14385-14420/com.example.ndkbuilddemo1 D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2022-05-12 17:19:32.074 14385-14420/com.example.ndkbuilddemo1 D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2022-05-12 17:19:32.053 14385-14385/com.example.ndkbuilddemo1 W/RenderThread: type=1400 audit(0.0:57): avc: denied { write } for name="property_service" dev="tmpfs" ino=8412 scontext=u:r:untrusted_app:s0:c155,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.ndkbuilddemo1
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 E/linker: normalize_path - invalid input: "C", the input path should be absolute
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 W/linker: Warning: unable to normalize "C" (ignoring)
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 E/linker: normalize_path - invalid input: "C", the input path should be absolute
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 W/linker: Warning: unable to normalize "C" (ignoring)
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 W/linker: Warning: "/data/app/com.example.ndkbuilddemo1--lwfCEoLIsl6NMByZznOPw==/lib/x86/libQt5Widgets.so" has unsupported flags DT_FLAGS_1=0x81 (ignoring unsupported flags)
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 W/linker: Warning: "/data/app/com.example.ndkbuilddemo1--lwfCEoLIsl6NMByZznOPw==/lib/x86/libQt5Gui.so" has unsupported flags DT_FLAGS_1=0x81 (ignoring unsupported flags)--------- beginning of crash
2022-05-12 17:19:32.121 14385-14385/com.example.ndkbuilddemo1 A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 14385 (e.ndkbuilddemo1), pid 14385 (e.ndkbuilddemo1)
2022-05-12 17:19:32.107 14385-14385/com.example.ndkbuilddemo1 W/linker: Warning: "/data/app/com.example.ndkbuilddemo1--lwfCEoLIsl6NMByZznOPw==/lib/x86/libQt5Gui.so" has unsupported flags DT_FLAGS_1=0x81 (ignoring unsupported flags)