QNetworkRequest not working on qt 5.8 and android 7.0



  • Hello everyone,
    since I updated my app to compile against qt 5.8, it stopped working. Every time I pass a QNetworkRequest to the QNetworkAccessManager.get() the app crashes with
    F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 585 (QtThread)
    If I try to debug it, the debugger jumps to an unknown assembly listing as soon as it tries to execute the function.
    Any suggestion on where to look would be much appreciated.
    Thanks



  • I found out that the problem was the lack of access to the OpenSSL libraries in Android 7.0
    I am 100% sure that I'm not making any network request that uses ssl.
    Is it possible that something in Qt 5.8 changed and it now somehow calls some functions from libcrypto or libssl even is no ssl request is explicitly made? It was working perfectly fine with Qt 5.7.1



  • I'm not sure about the behavior when these libraries are missing, but in my opinion modern applications should be able to handle SSL so I suggest to include the libraries anyways.
    If you want to avoid having to manually build and provide the SSL libraries for Android, V-Play Engine comes with already bundled SSL libs since version 2.10.0.

    Best,
    GT



  • Hi,

    I have the same issue in my android app when run on Android 7. The application not uses https, and the request is make by javascript with XMLHttpRequest in a qml component.

    The android application crash when start a new request for the remote service.

    Why Qt require openssl for http request?

    I follow the tip described here: http://doc.qt.io/qt-5/opensslsupport.html, but not work for me.

    Any solution for this?



  • I found a solution for this problem with OpenSSL in Android 7.

    Create a sh file with the code below and execute in same dir of openssl tar.gz file. The version tested is 1.0.2. The file can be download here: https://www.openssl.org/source/. This script will generate the .so files: libcrypto.so and libssl.so.

    #!/bin/sh
    tar xzvf ~/Downloads/openssl-1.0.2g.tar.gz
    cd openssl-1.0.2g
    # path to android ndk folder
    export NDK=~/qt/android-ndk-r13b
    $NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-androideabi-4.6 --install-dir=`pwd`/android-toolchain-arm
    export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
    export TOOL=arm-linux-androideabi
    export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
    export CC=$NDK_TOOLCHAIN_BASENAME-gcc
    export CXX=$NDK_TOOLCHAIN_BASENAME-g++
    export LINK=${CXX}
    export LD=$NDK_TOOLCHAIN_BASENAME-ld
    export AR=$NDK_TOOLCHAIN_BASENAME-ar
    export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
    export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
    export ARCH_FLAGS="-mthumb"
    export ARCH_LINK=
    export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
    export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
    export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
    export LDFLAGS=" ${ARCH_LINK} "
    # the target of libraries files is armv7
    cd ~/Downloads/openssl-1.0.2g && ./Configure android-armv7 shared
    

    After run the script, open the Makefile and execute the step 5 described here: http://doc.qt.io/qt-5/opensslsupport.html. After edit the Makefile, execute the next commands (into openssl extracted folder) to generate the .so files.

    make clean && PATH=$TOOLCHAIN_PATH:$PATH make
    

    Now, move the .so files to your project.
    To package the .so files into apk, add the below code into .pro file of the project:

        contains(ANDROID_TARGET_ARCH,arm) {
            # update the path of the libraries where you put in your project.
            # I put in: myapp/android/libs/openssl/armeabi-v7a/:
            ANDROID_EXTRA_LIBS = \
                $$PWD/android/libs/openssl/armeabi-v7a/libcrypto.so \
                $$PWD/android/libs/openssl/armeabi-v7a/ibssl.so
        }
    

  • Qt Champions 2016

    @Joseneas uups ... just did test running one of my projects moved from 5.7 to 5.8 on a Google Pixel C tablet with Android 7.0
    and the same happens here: App is crashing

    W linker  : library "libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/org.ekkescorner.tt-2/lib/arm/libQt5Core.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.
    W linker  : library "libssl.so" ("/system/lib/libssl.so") needed or dlopened by "/data/app/org.ekkescorner.tt-2/lib/arm/libQt5Core.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve CRYPTO_free
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve EVP_CipherFinal
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_ctrl
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve SSL_ctrl
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve EC_get_builtin_curves
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot resolve EC_curve_nist2nid
    W libtimetracker10_te_qt.so: (null):0 ((null)): qt.network.ssl: QSslSocket: cannot call unresolved function OPENSSL_add_all_algorithms_conf
    F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 24205 (QtThread)
    

    running same app from Qt 5.7 all works on Android 7
    this app only uses http://


  • Qt Champions 2016

    This post is deleted!

  • Qt Champions 2016

    This post is deleted!

  • Qt Champions 2016

    I'm trying to make it run - see discussion in https://forum.qt.io/topic/76978/android-how-to-install-so-file



  • Hi,

    I compiled libcrypt.so and libssl.so (v1.1.0e). But, when i include in my app i have a crash in android 7.
    If i put off this .so i can test my app in Android 7 but with this warning

    W linker : library "libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/pe.com.medicalint-1/lib/arm/libQt5Core.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.
    W linker : library "libssl.so" ("/system/lib/libssl.so") needed or dlopened by "/data/app/pe.com.medicalint-1/lib/arm/libQt5Core.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.

    What can i do for do my App in Android 7?


  • Qt Champions 2016

    @Tchaumont for me it works. see also here
    https://forum.qt.io/topic/77150/qt-5-8-qnam-openssl-crash-openssl_threads
    from comments seems to work for others too


  • Moderators

    @Tchaumont said in QNetworkRequest not working on qt 5.8 and android 7.0:

    i have a crash in android 7

    What exactly happens? Error message?


Log in to reply