How come elements don't appear in Android Emulator but do appear on mobile device?
-
Background information
Using
Windows 11Deploying to Android virtual device doesn't make elements appear as they should as we'll see from the photos
Android_Qt_6_8_0_Clang_x86_64-Debug
Galaxy Nexus (x86_64 Android 13.0 SDK 33)Deploying to an Android mobile device makes elements appear as they should as we'll see from the photos
Android_Qt_6_8_0_Clang_arm64_v8a-Debug
moto g(30)Get some red messages in application output when deploying to Android virtual device in case it matters
W OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... W OpenGLRenderer: Failed to initialize 101010-2 format, error = EGL_SUCCESS
W Parcel : Expecting binder but got null!
E emuglGLESv2_enc: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2183 GL error 0x502
Code for the project
The page contents I'm trying to make appear. PageSettings.qml
https://github.com/ProjectsKoryHasWorkedOn/DanceSyllabusesApp_2024/blob/main/import/qml/PageSettings.qmlThe Main.QML file with the StackView at the bottom. Can call PageSettings.qml from this
https://github.com/ProjectsKoryHasWorkedOn/DanceSyllabusesApp_2024/blob/main/import/qml/Main.qml
Problem description
Followed the steps found here
https://spaceofna-com.translate.goog/android-studio-avd-gl-error-0x502/?_x_tr_sl=ko&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=scDiscovered that I can make the elements on PageSettings.qml appear if I set
Emulated performance > Graphics: SoftwareAlthough it looks awful
https://ibb.co/FVkYLkN
https://postimg.cc/xcmw7Nx0
However, the moment I set Emulated Performance > Graphics: Automatic, all I can see is the Switch
https://ibb.co/31K2NXc
https://postimg.cc/JyRCj7QR
All of the elements on PageSettings.qml appear on one's mobile device how I'd hoped it would
https://ibb.co/FYvVD22
https://postimg.cc/4nYk6SpH
Does anybody have any ideas as to how to make the elements appear on the virtual device nicely? Perhaps it's best if I don't debug on it if the issue is with it and not with something I've done
What I tried to do to work out what was causing the problem
So PageSettings.qml has this tree (like these are all the children of Window) from what I understand
Window > StackView > Item > Item > ScrollView > ColumnLayout > (Button, Text, and Switch elements)Discovered two things:
(1) If I move the Item (bolded) contents out of PageSettings.qml and into Main.qml (like unnest it), it appears on the virtual device how it should
So this nesting makes it appear: Window > Item > ScrollView > ColumnLayout > (Button, Text, and Switch elements)
Proof of this can be seen here
https://ibb.co/5Fn2Vz2
https://postimg.cc/YjTcbzxnSurely if it works on one's phone though with the original nesting, it should work as well on the virtual device but that doesn't seem to be the case
(2) If I keep everything as it was originally but comment out ScrollView (bolded) in PageSettings.qml, it appears on the virtual device
Proof
https://postimg.cc/06ZRngtDSo this nesting makes it appear: Window > StackView > Item > Item > ColumnLayout > (Button, Text, and Switch elements)
The fact that it works (on the Android Emulator) if I leave out EITHER a StackView or ScrollView and that it works (only a mobile device, not on Android Emulator) if I have both a StackView and ScrollView leads to me believe that it isn't a problem with one's code
But I could be wrong about this.
-
-
Which emulator and which physical device are you using? Are they the same? Same screen size? Portrait or Landscape?
-
Hello,
I using emulating on a Galaxy Nexus (x86_64 / Android 13.0 SDK 33 (google APIS) / 720 x 1280 display) . It's like the first one that comes up in the list of virtual devices to emulate on.I was also deploying to a motorola g(30) (arm64 / Android 12.0 / 720 x 1600 display I think) physical device
-
Well, then you are emulating a different hardware, than the one you physically use.
That's where the difference comes from. -
@Axel-Spoerl Are you recommending that I try emulating to a particular device from the available options to see if it makes a difference? I can't say with 100% certainty that the display will have the same issue but it seems to be particular to the Android Emulator like it not displaying either all of the page elements (if I have it set to emulated performance graphics: automatic / https://postimg.cc/RW7z3JKP) or it displaying all the page elements poorly (if I have it set to emulated performance graphics: software / https://postimg.cc/xcmw7Nx0). I'm suspecting it shows up on mobile devices OK but I only have around 3 mobile devices I can test. Also not sure if computer hardware / operating system / etc. makes a difference. Too many variables. Wonder if companies generally deploy to the actual mobile device too like maybe using the Android Emulator is less common in industry
Edit: Just in process of re-uploading images to different provider as ImgBB servers are down
-
Emulation adds layers to about everything. It's therefore more error-prone and never 100% on the level of a physical device.
The fact that it works on physical devices, indicates that the issue is more likely to be in the emulation layer, than in Qt.