Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to create openssl library for Android?
QtWS25 Last Chance

How to create openssl library for Android?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
14 Posts 6 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lqsa
    wrote on last edited by
    #1

    Hello,

    My Android app uses SSL. It works perfect, except on Android 7. Searching I've read that Google has changed the openssl libraries with another ones, so, the app doesn't work.

    The solution seems to add OpenSSL libraries with the app. After read and compile the OpenSSL libraries following the Qt documentation, link text, my app doesn't work. I've added the generated .so libraries but the app simple crash.

    Please, could you give me more detailed steps to compile the library?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should first use the debugger to find exactly where your application crashes. If you have added the OpenSSL libraries as recommended, then you might be hitting something else.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lqsa
        wrote on last edited by
        #3

        Crashes when the app is loaded. It doesn't arrives on main function.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok... Then did you try running a dummy application ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lqsa
            wrote on last edited by
            #5

            I've created a dummy app and included the libssl.so and libcrypto.so libraries. The APK is generated correctly.

            The dummy application crashes on QSslConfiguration:

            int main(int argc, char *argv[])
            {
                QNetworkAccessManager *_nam;
                QNetworkSession *_ns;
                QSslConfiguration _sslConfiguration;
                QNetworkProxyFactory::setUseSystemConfiguration(true);
            ...
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That's an invalid dummy application, you are missing a QApplication object. The crash you have here might not be related to your original problem.

              By the way, which version of OpenSSL are you using ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              L 1 Reply Last reply
              0
              • L Offline
                L Offline
                lqsa
                wrote on last edited by
                #7

                New code:

                int main(int argc, char *argv[])
                {
                    QGuiApplication app(argc, argv);
                
                    QQmlApplicationEngine engine;
                
                    QNetworkAccessManager *_nam;
                    QNetworkSession *_ns;
                    QSslConfiguration _sslConfiguration;
                    QNetworkProxyFactory::setUseSystemConfiguration(true);
                

                It crash at startup. Really the previous code also crash at startup.

                I've tried with the latest version, 1.0.2k and 0.9.8za

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  Geraud
                  wrote on last edited by
                  #8

                  I had the same issue, I just built the OpenSSL library for Android, and it is embedded in my APK. As a result, Qt is able to use it properly. But clearly we need a longer term solution there. (aka using Google's native SSL)

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    That's an invalid dummy application, you are missing a QApplication object. The crash you have here might not be related to your original problem.

                    By the way, which version of OpenSSL are you using ?

                    L Offline
                    L Offline
                    lqsa
                    wrote on last edited by lqsa
                    #9

                    @SGaist I think that I'm not compiling correctly.

                    My environment is QT 5.7 and Windows 10 Pro. I've downloaded the last NDK, 13b, last JDK 1.8_102 and last SDK (installed from the last version of Android Studio, 2.1), Like all the documentation steps for building the library are in linux, I've installed the ubuntu bash provided by Windows 10, and do these steps:

                    • I've download and installed the NDK on the ubuntu bash (the same that I've on Windows).
                    • I've followed the steps on the Qt documentation: <VER> parameter with 4.9, <NDK_HOST> with linux-x86_64, <ANDROID_PLATFORM> with android-16

                    What value must be ANDROID_PLATFORM?

                    After that, it generates the .so libraries.

                    On the pro file, I've put:

                    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
                        ANDROID_EXTRA_LIBS = \
                            $${SSL_LIBS_PATH}/armeabi-v7a/libssl.so \
                            $${SSL_LIBS_PATH}/armeabi-v7a/libcrypto.so
                    }
                    

                    When the APK is generated, the libraries are correctly inside the lib/armeabi-v7a directory.

                    Could be the problem the ANDROID_PLATFORM parameter? The compilation on linux?

                    I've tried anothers like: [http://stackoverflow.com/questions/11929773/compiling-the-latest-openssl-for-android](link url) but always the same. The libraries are generated, but when I put it on my project, the app crashes.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      The 13 series has currently a bug. Download the r10e version.

                      More info there

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        lqsa
                        wrote on last edited by
                        #11

                        I've downloaded the 13 because before I had the r10e and occurs the same, so, I've tried with the latest.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AlGrenadine
                          wrote on last edited by
                          #12

                          I've got a crash on Android 7 only when posting a QNetworkRequest... It's an http address not https but i've got warnings it doesn't find ssl functions... So adding openssl library in the apk should fix it ?

                          jsulmJ 1 Reply Last reply
                          0
                          • A AlGrenadine

                            I've got a crash on Android 7 only when posting a QNetworkRequest... It's an http address not https but i've got warnings it doesn't find ssl functions... So adding openssl library in the apk should fix it ?

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @AlGrenadine If your app does not access HTTPS then you can just ignore the SSL warnings.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • GTDevG Offline
                              GTDevG Offline
                              GTDev
                              wrote on last edited by
                              #14

                              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

                              Senior Developer at Felgo - https://felgo.com/qt

                              Develop mobile Apps for iOS & Android with Qt
                              Felgo is an official Qt Technology Partner

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved