How to create openssl library for Android?
-
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?
-
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.
-
Ok... Then did you try running a dummy application ?
-
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); ...
-
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 ?
-
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
-
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 ?
@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.
-
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 ?
-
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 ?
@AlGrenadine If your app does not access HTTPS then you can just ignore the SSL warnings.
-
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