Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What version of android is the APK file for? #172

Open
ljgdasfhk opened this issue Nov 30, 2024 · 29 comments
Open

What version of android is the APK file for? #172

ljgdasfhk opened this issue Nov 30, 2024 · 29 comments
Labels
chore Updating grunt tasks etc; no production code change packaging Packaging
Milestone

Comments

@ljgdasfhk
Copy link

I downloaded the file "qTox-nightly.arm64-v8a.apk" on my phone with android v7.1.2,
but when I try to install it I get the message "error parsing package".
Is it possible to lower the minimum requirements for the android version if this is the reason?

@iphydf
Copy link
Member

iphydf commented Nov 30, 2024

I'm not sure which version. I'll have a look in a bit. It works on my phone, which is Android 14. The ndk target version is all over the place in the build. I'll look into getting that down to the lowest possible version.

Note that qTox really doesn't work very well on android even when it does work, it's currently more of an experiment.

@iphydf iphydf added packaging Packaging chore Updating grunt tasks etc; no production code change labels Nov 30, 2024
@iphydf iphydf added this to the v1.18.1 milestone Nov 30, 2024
@ljgdasfhk
Copy link
Author

ljgdasfhk commented Nov 30, 2024

this is a very useful experiment!
please try to downgrade the ndk version so that it can be used on android v7.0
otherwise I'll have to go get a new phone

@iphydf
Copy link
Member

iphydf commented Nov 30, 2024

Can you try the apk from #173? https://github.com/TokTok/qTox/actions/runs/12100028404/job/33738195300?pr=173#step:5:22

@iphydf
Copy link
Member

iphydf commented Nov 30, 2024

Also, which CPU does your phone have? If you don't know, then which manufacturer/model is your phone? We're currently only building arm64, but Android 7 is possibly running on 32 bit ARM.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 1, 2024

ASUS zc550kl, Qualcomm Snapdragon 615 MSM8939 -- arm64 v8a is just right for my processor.
Now the application is installed, but crashes when launched.
I hope I can help with testing somehow.
(I used to think that qt6 requires version 33 of the SDK)

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

If you can run adb logcat and find out why it crashes, maybe we can fix that.

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

@ljgdasfhk
Copy link
Author

The new version also crashes, but now the word QTOX has time to appear on the screen.

I'm currently learning how to use debugging via USB.
As soon as I succeed, I'll show the log.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 1, 2024

logcat.txt
sorry for such a long log
if there is any way to record only what we need, tell me how to do it

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

I think this is the error. I'm not sure how to fix that. There's still #173. I don't know if that'll help at all.

12-01 21:14:46.021  3840  3840 V GoogleTagManager: Dispatch call queued. Dispatch will run once initialization is complete.
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: obj == null
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]     in call to CallVoidMethodV
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]     from void org.qtproject.qt.android.QtNative.startQtApplication()
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470] "qtMainLoopThread" prio=5 tid=12 Runnable
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   | group="main" sCount=0 dsCount=0 obj=0x12c89c10 self=0x7f8bb60e00
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   | sysTid=5639 nice=0 cgrp=default sched=0/0 handle=0x7f9583d450
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   | state=R schedstat=( 367843698 17770307 207 ) utm=32 stm=4 core=6 HZ=100
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   | stack=0x7f9573b000-0x7f9573d000 stackSize=1037KB
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   | held mutexes= "mutator lock"(shared held)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #00 pc 00000000004ce184  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #01 pc 00000000004ce180  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #02 pc 00000000004a1008  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #03 pc 0000000000326f00  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1164)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #04 pc 00000000003272b0  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+188)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #05 pc 00000000004d4e14  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Core_arm64-v8a.so (_ZNK10QJniObject15callVoidMethodVEP7_JNIEnvP10_jmethodIDz+136)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #06 pc 000000000008b1d4  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #07 pc 000000000008b108  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #08 pc 000000000008a428  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #09 pc 000000000007f1c4  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #10 pc 0000000000089cfc  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #11 pc 00000000003c20a4  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Gui_arm64-v8a.so (_ZN14QWindowPrivate6createEb+244)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #12 pc 00000000003852b4  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Widgets_arm64-v8a.so (_ZN14QWidgetPrivate6createEv+724)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #13 pc 0000000000383d74  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Widgets_arm64-v8a.so (_ZN7QWidget6createEybb+272)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #14 pc 0000000000392338  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Widgets_arm64-v8a.so (_ZN14QWidgetPrivate10setVisibleEb+264)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #15 pc 000000000050a194  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Widgets_arm64-v8a.so (_ZN14QDialogPrivate10setVisibleEb+220)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #16 pc 0000000000509948  /data/app/org.qtproject.example.qtox-1/lib/arm64/libQt6Widgets_arm64-v8a.so (_ZN7QDialog4execEv+156)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #17 pc 0000000000cd7bb4  /data/app/org.qtproject.example.qtox-1/lib/arm64/libqtox_arm64-v8a.so (_ZN5Nexus9showLoginERK7QString+284)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #18 pc 0000000000c99cd8  /data/app/org.qtproject.example.qtox-1/lib/arm64/libqtox_arm64-v8a.so (_ZN10AppManager3runEv+9168)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #19 pc 0000000000c964c8  /data/app/org.qtproject.example.qtox-1/lib/arm64/libqtox_arm64-v8a.so (main+56)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #20 pc 000000000005c1a8  /data/app/org.qtproject.example.qtox-1/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so (???)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   native: #21 pc 0000000000049558  /data/app/org.qtproject.example.qtox-1/oat/arm64/base.odex (Java_org_qtproject_qt_android_QtNative_startQtApplication__+120)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   at org.qtproject.qt.android.QtNative.startQtApplication(Native method)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   at org.qtproject.qt.android.QtNative$$ExternalSyntheticLambda4.run(D8$$SyntheticClass:0)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   at org.qtproject.qt.android.QtThread$1.run(QtThread.java:25)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]   at java.lang.Thread.run(Thread.java:761)
12-01 21:14:46.227  5623  5639 F art     : art/runtime/java_vm_ext.cc:470]

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

It does move into _ZN5Nexus9showLoginERK7QString+284. I need to get the .so to see what's happening at offset 284 in that method.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 1, 2024

It does move into _ZN5Nexus9showLoginERK7QString+284. I need to get the .so to see what's happening at offset 284 in that method.

do you need any library from my phone? libart.so?

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

No, I don't think so. I don't really have a clue what is going wrong there. I'll have a look at our binary in a bit.

@ljgdasfhk
Copy link
Author

I found it strange that qtox does not require permissions to access files, camera, microphone, etc...

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

It does require it, but doesn't ask for it yet, so it won't get access from Android to those things. I need to add those requests to the Android manifest so the OS can know we need them.

@iphydf
Copy link
Member

iphydf commented Dec 1, 2024

https://github.com/TokTok/qTox/actions/runs/12110087957/job/33759961201?pr=182#step:5:24 <- here is a debug build. Maybe it'll give us more information about what's going wrong.

https://github.com/TokTok/qTox/releases/download/nightly/qTox-nightly-arm64-v8a-debug.apk is always the most up-to-date one (currently the same as above).

@ljgdasfhk
Copy link
Author

when installing i get "error parsing package"

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

#185 try the release APK in this PR build.

Also run adb logcat while installing and see if you get more information from the parsing package error.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 2, 2024

run adb logcat while installing
logcat.txt
This is the apk installation log from the link

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

Can you tell me around what time you tried installing it? There are a bunch of things in that log about qtox, one of them is the obj == NULL error, another is about permissions. Can you try uninstalling it first before installing the debug version? If that doesn't work, install the release version, run it again, and paste the logs around the time you tried starting it.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 2, 2024

downloaded both files from the links above
for both files I did the following:

  1. enabled USB debugging on the phone
  2. launched ADB on the computer adb logcat
  3. connected the cable
  4. clicked on the file and selected "install"
  5. the message "error parsing the package" appeared
  6. disconnected the cable

logcat-debug.txt
logcat-release.txt

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

I see the manifest is wrong:

                android:minSdkVersion="28"
                android:targetSdkVersion="34"

We need #173.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 2, 2024

new nightly builds are being installed
I recorded the debug version launch log
logcat-debug.txt
look at the end of the file

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

Interesting, so what I see is:

_ZN5Nexus9showLoginERK7QString+224 is

LoginScreen loginScreen{settings.getPaths(), *style, settings.getThemeColor(), profileName};

_ZN11LoginScreenC1ER5PathsR5StyleiRK7QStringP7QWidget+1552 is

reset(initialProfileName);

_ZN11LoginScreen5resetERK7QString+72 is

ui->newUsername->clear();

Then a bunch of things happen inside Qt:

_ZN9QLineEdit5clearEv+52 is https://github.com/qt/qtbase/blob/9cb0d48aae81c5436bda783b64721d0b77bc3f6c/src/widgets/widgets/qlineedit.cpp#L1295

_ZN18QWidgetLineControl5clearEv+104 is https://github.com/qt/qtbase/blob/9cb0d48aae81c5436bda783b64721d0b77bc3f6c/src/widgets/widgets/qwidgetlinecontrol.cpp#L249

_ZN18QWidgetLineControl12finishChangeEibb+860 is https://github.com/qt/qtbase/blob/9cb0d48aae81c5436bda783b64721d0b77bc3f6c/src/widgets/widgets/qwidgetlinecontrol.cpp#L724

_ZN18QWidgetLineControl25emitCursorPositionChangedEv+96 is https://github.com/qt/qtbase/blob/9cb0d48aae81c5436bda783b64721d0b77bc3f6c/src/widgets/widgets/qwidgetlinecontrol.cpp#L1400

_ZN18QWidgetLineControl21cursorPositionChangedEii+108 is inside a moc generated cpp file that calls QMetaObject::activate.

_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+124 is 68e770: 94000302 bl 0x68f378 <_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0xc84>.

From here, it gets a bit difficult, because that code is inlined, but it's roughly here: https://github.com/qt/qtbase/blob/9cb0d48aae81c5436bda783b64721d0b77bc3f6c/src/corelib/kernel/qobject.cpp#L4224.

The rest of the stack trace (which doesn't have symbols, but I checked with objdump):

  • 68fb40 QtCore _ZN11QMetaObject8activateEP7QObjectPKS_iPPv
  • 5e8b00 QtCore _ZN16QCoreApplication11qt_metacallEN11QMetaObject4CallEiPPv
  • 7dc668 QtWidgets _ZN9QLineEdit11qt_metacallEN11QMetaObject4CallEiPPv
  • 7dc760 QtWidgets _ZN9QLineEdit11qt_metacallEN11QMetaObject4CallEiPPv
  • 7dc7c4 QtWidgets _ZN9QLineEdit11qt_metacallEN11QMetaObject4CallEiPPv
  • 7dc1ac QtWidgets _ZN9QLineEdit11qt_metacallEN11QMetaObject4CallEiPPv
  • 7d5060 QtWidgets _ZN9QLineEdit11qt_metacallEN11QMetaObject4CallEiPPv
  • 7d5128 QtWidgets: 7d5128: 94142cf2 bl 0xce04f0 <__dynamic_cast@plt>
  • 23e0 libc++: 23e0: 000000b0 udf #0xb0

So there's a dynamic_cast that goes wrong somewhere in QLineEdit::qt_metacall, and interestingly, it seems to jump right into non-executable code. 0x23e0 in libc++_shared.so is not code, it's data. In particular, that's Elf32_Sym/Elf64_Sym data. I don't think it's supposed to be executing that (even with @plt).

At this point it's pretty difficult to figure out why that's happening unless we somehow manage to get an lldb or gdb running (debug server on the device and debugger client on the computer), or maybe compile with -finstrument-functions and get a full execution trace to see what leads up to that dynamic_cast.

One idea I'd have is to try to build the Qt library fully static (avoiding PLT lookups). I don't know whether that can work at all, but it's something we can try.

@ljgdasfhk
Copy link
Author

ljgdasfhk commented Dec 2, 2024

if i had gdbserver i could copy it to the device
In addition, I could provide remote access to my computer

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

Building a fully static Qt for Android is basically impossible. I just tried it, and Qt-for-Android is really not made for that. It does things when the JVM loads the shared objects. It would be a significant amount of work on Qt core stuff to make that work.

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

I've never debugged a native app on Android. This stackoverflow answer explains how. It crashes too quickly to attach a gdbserver, but I can add something to main() to wait for a volatile bool to be true, which you can then set to true in gdb and see what happens.

This is definitely outside the realm of things I've done before on Android :P. I don't think I can assist very much in that debugging, but I'll make a PR with the busy-wait bool in case you want to try that.

@ljgdasfhk
Copy link
Author

do you have a gdbserver that i could copy to the device for debugging later?
could you give it to me?

@iphydf
Copy link
Member

iphydf commented Dec 2, 2024

#188 <- this will produce an apk in the android builds with that infinite loop in it. If you manage to attach a gdbserver, this will let you continue the program by setting the global variable to true.

https://gist.github.com/sekkr1/6adf2741ed3bc741b53ab276d35fd047 seems to explain how to get a gdbserver onto your device.

This is the lldb-server I got from my NDK: lldb-server.gz. You'll need to attach lldb instead of gdb to this. Maybe if you find an older NDK, it'll have gdbserver in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Updating grunt tasks etc; no production code change packaging Packaging
Projects
None yet
Development

No branches or pull requests

2 participants