Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QNetwork on mobile app



  • Hello everyone,
    Will QNetwork work on mobile for qt. I compiled with the android qt compiler and for some reason app won't connect. It works perfectly fine on desktop but not on Mobile.
    Any ideas?



  • @Alfie-Anil

    Different classes of network are used in my applications compiled for Android. They work as expected.

    The apps work through WiFi with internal network addresses and also through the provider connection as long as there are no typical limitation as to be expected through outside access.

    You must allow network access through the AndroidManifest and may have to allow separately on your device. However, if you are not allowing the access the application would be stopped by Android anyhow.



  • @koahnig Thanks for the reply.
    I added

    <uses-permission android:name="android.permission.INTERNET" />
    

    to the Android manifest files. Could you guide me on how I could allow separately on my device please.



  • @Alfie-Anil

    This might depend on your actual Android version.

    Under Android version 10 you can change the access rights by pressing longer on the app icon as you want to remove/uninstall it. However, the menu bar allows also to get "info" of the app. Under there you can change the access rights.

    With Android 9 I need to go to "settings"->"Apps" where is another entry "Apps". Inthere are all applications listed and you need to navigate to your app.

    However, there might be also differences because of manufacturer dependent gui. Better google for access rights with specific, possibly manufacturer dependent Android version.



  • hello @koahnig . I've done both of these, on the phone I have set it to allow wifi and mobile data use, but it still isn't connecting. Any ideas? thanks



  • @Alfie-Anil said in QNetwork on mobile app:

    but it still isn't connecting

    So it "does not work" but you cannot find any error reported?



  • @JonB That's my bad, This is the error message that comes up:
    (Prototype1 is the name of the file by the way).

    W QtThread: type=1400 audit(0.0:4635): avc: denied { ioctl } for path="socket:[239265]" dev="sockfs" ino=239265 ioctlcmd=0x8b07 scontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tclass=netlink_route_socket permissive=0
    I chatty  : uid=10146(org.qtproject.example.Prototype1) identical 3 lines
    W QtThread: type=1400 audit(0.0:4639): avc: denied { ioctl } for path="socket:[239265]" dev="sockfs" ino=239265 ioctlcmd=0x8b07 scontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tclass=netlink_route_socket permissive=0
    E linker  : library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/lib/arm/libQt5Core_armeabi-v7a.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/lib/arm:/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/base.apk!/lib/armeabi-v7a", permitted_paths="/data:/mnt/expand:/data/data/org.qtproject.example.Prototype1"]
    W libPrototype1_armeabi-v7a.so: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
    D AwareBitmapCacher: handleInit switch not opened pid=16534
    I mple.Prototype: Starting profile saver IsSaveProfileNow end.
    


  • @Alfie-Anil said in QNetwork on mobile app:

    QSslSocket::connectToHostEncrypted: TLS initialization failed

    for some reason app won't connect

    I can't tell you why, but this is why it's failing. Does it fail on just one site? Only https sites? Do you have to supply some SSL libraries with your Qt app?

    Also what about:

    E linker  : library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/lib/arm/libQt5Core_armeabi-v7a.so"
    is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/lib/arm:/data/app/org.qtproject.example.Prototype1-Tdx26qf-ZSiA805j_rz_CA==/base.apk!/lib/armeabi-v7a",
    permitted_paths="/data:/mnt/expand:/data/data/org.qtproject.example.Prototype1"]
    

    That looks a bit worrying, is that the cause?


Log in to reply