I’ve got problems with applications based on Qt Quick – they don’t work properly on Android emulators with API > 24 (newer than Android 7.0).
Building and deploying are finished OK. But the application works only for the first time – if I quit an application (tap "back" or "home" or close the application) and open it again, only blank screen is appeared. This problems stays until I reinstall the app or clear app cache.
Gif with problem representing:
There’s no that problem on real phones. Projects built in Android Studio don’t have such problems as well.
Application based on Qt Widgets works correctly without blank screens.
The only suspicious thing I got from logcat
is that (it logged after the second start of application):
06-04 10:06:24.976 1899 1989 W InputDispatcher: channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-04 10:06:24.977 1899 1989 E InputDispatcher: channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-04 10:06:24.977 1756 1756 I Zygote : Process 4511 exited cleanly (0)
06-04 10:06:24.977 1899 2568 I WindowManager: WIN DEATH: Window{c7fea10 u0 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity}
06-04 10:06:24.977 1899 2568 W InputDispatcher: Attempted to unregister already unregistered input channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)'
06-04 10:06:24.977 1899 3872 I ActivityManager: Process org.qtproject.example.testandroidqml (pid 4511) has died: cch CRE
06-04 10:06:24.977 1899 1917 W libprocessgroup: kill(-4511, 9) failed: No such process
06-04 10:06:24.977 1899 1917 I libprocessgroup: Successfully killed process cgroup uid 10086 pid 4511 in 0ms
06-04 10:06:24.978 1755 2486 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{86cbd61 token=Token{a4f68c8 ActivityRecord{b83956b u0 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity t12}}}#0
06-04 10:06:24.979 1899 1922 W ActivityManager: setHasOverlayUi called on unknown pid: 4511
06-04 10:06:24.979 1755 1755 W SurfaceFlinger: couldn't log to binary event log: overflow.
Why does it happen and how can I solve this issue?
My conditions:
- Ubuntu 22.04
- Project is simple – default one created with Qt Creator + red rectangle in
main.qml
added. It is built under Qt 5.15 with CMake - Emulator "Pixel XL" under API 28 (Android 9.0) from Android Studio
I tried:
- different emulators and different APIs (it doesn’t work anywhere except Android 7.0)
- deploying with Qt Creator and manual apk installations – doesn’t affect anything
2
Answers
It seems like I have found the solution.
The problem is solved when I set the value "Software" instead of "Automatic" for the option "Graphics" in the emulator perfomance settings (Android Studio's device manager).
Or you can set it manually in the emulator config file by changing
hw.gpu.mode
property value tosoftware
.It works slower now but at least it works!
The problem is linked with inputs and outputs between the application and the Android framework. The logs that you gave point out that the input channel you have used is being closed after the first time of running the application.
Few solutions you may try:
1. Check for Qt Updates:
Make sure that you have the current version of Qt development framework if not consider upgrading to a newer Long Term Support (LTS) version if there is one available. Different versions of Qt have bug fixes and compatibility enhancements The previous category of Qt releases relates to bug fixes on the different versions of Qt as well as other compatibility enhancements. Some of the things that one can discover which is easily found on the forum or Qt documentation are ideas to fix problems arising from Android emulators.
2. Investigate Input Channel Issue:
Real issue lies with input channel as shown in the log messages. You may check online forum like https://forum.qt.io/ and look for threads that have specifically mentioned the possible
InputDispatcher channel
problems with QT applications in Android. You may also try moving the application to debug and release version to check out which mode has more information regarding the input channel problem.3. Alternative Deployment Methods:
Regarding your previous attempts, you have made attempts using Qt Creator and installing
APK
directly, but it is suggested to venture out to other possibilities, one of them being the deployment directly in Android Studio. This could perhaps assist in eliminating applicable deployment-associated concerns.4. Test on a Physical Device:
As you are agree here that the problem doesn’t happen on real devices that are running the developed application. Using different type and version of physical device can also help to confirm whether the problem is with emulators or can be linked to the config of emulator you are using.
Additional Tips: