OpenSSL for Android support
-
This works on macOS building Android arm, arm7, and x86 OpenSSL libs.
- I had to I revert to using Android NDK r10e to get it to work.
- I never could NOT get it to build on Ubuntu 18.04 even with NDK r10e
See: https://github.com/esutton/android-openssl
Android build environment for OpenSSL
- Supports build for multiple architectures - ARM, ARMv7, X86
- Uses OpenSSL source codes
- Integrated with Android.mk build
- Output directories for libcrypto and libssl are set in Android.mk
- arch-armeabi/lib/
- arch-armeabi-v7a/lib/
- arch-x86/lib/
Advice: Do NOT use OpenSSL binaries you find laying about the Internet.
How to compile
cd jni/openssl ./build.sh
Optionally, set variables on the beginning of the
build.sh
according to your Android NDK.In the global JNI Android.mk you can then simply include Android.mk from openssl directory so the
static or dynamic libraries are linked to the rest of your project.include jni/openssl/Android.mk
Include paths for header files are not set, headers will be after compilation present at
jni/openssl/sources/include
Notes
Advice: Do not use pre-built OpenSSL libs you find laying around the Internet
macOS Using Android NDK r10e
On macOS, building OpenSSL fails when using NDK 11 or greater.
Work-around is to download and use r10e to build OpenSSL.
- Please download Android NDK r10e and update ANDROID_NDK
- https://developer.android.com/ndk/downloads/older_releases
- https://dl.google.com/android/repository/android-ndk-r10e-windows-x86_64.zip
- Copy the extracted downloaded ndk folder to your $ANDROID_SDK folder and rename to ndk-r10e
- Set ANDROID_NDK environment variable:
ANDROID_NDK=$ANDROID_SDK/ndk-r10e
-
A couple of updates:
- I tried compiling
openssl-1.1.0h
(current stable version) against the old android ndk (r10e) because people seem to have reported that working. Well, it compiled, but it didn't work in the app. The errors were similar to the ones I got with @mateczek's script. I also noticed
qt.network.ssl: Incompatible version of OpenSSL
error, but that could have been present with @mateczek's result too, and I could have just missed it. So, it resulted in a similar output. - Then I decided to give
openssl-1.0.2o
(current stable LTS version) a try. To my astonishment, it compiled, and it worked in the app!
So, the conclusion is:
- use
openssl-1.0.x
LTS version, until it's supported - use
android-ndk-r10e
, until it's supported - use these instructions
The remaining question: is this a known issue? Is there a bug to update openssl support to more recent openssl and android ndk versions?
For reference, I run OpenSUSE Tumbleweed and keep it updated. Qt Creator 4.7.0. Qt 5.11.1. I'm happy to test and provide additional information if anyone has any ideas.
- I tried compiling
-
A couple of updates:
- I tried compiling
openssl-1.1.0h
(current stable version) against the old android ndk (r10e) because people seem to have reported that working. Well, it compiled, but it didn't work in the app. The errors were similar to the ones I got with @mateczek's script. I also noticed
qt.network.ssl: Incompatible version of OpenSSL
error, but that could have been present with @mateczek's result too, and I could have just missed it. So, it resulted in a similar output. - Then I decided to give
openssl-1.0.2o
(current stable LTS version) a try. To my astonishment, it compiled, and it worked in the app!
So, the conclusion is:
- use
openssl-1.0.x
LTS version, until it's supported - use
android-ndk-r10e
, until it's supported - use these instructions
The remaining question: is this a known issue? Is there a bug to update openssl support to more recent openssl and android ndk versions?
For reference, I run OpenSUSE Tumbleweed and keep it updated. Qt Creator 4.7.0. Qt 5.11.1. I'm happy to test and provide additional information if anyone has any ideas.
@Unix-One said in OpenSSL for Android support:
The remaining question: is this a known issue? Is there a bug to update openssl support to more recent openssl and android ndk versions?
Checking Qt's source code, you'll find that OpenSSL 1.1.x is not yet supported...
... if (!_q_SSLeay || q_SSLeay() >= 0x10100000L) { // OpenSSL 1.1 has deprecated and removed SSLeay. We consider a failure to // resolve this symbol as a failure to resolve symbols. // The right operand of '||' above is ... a bit of paranoia. delete libs.first; delete libs.second; qCWarning(lcSsl, "Incompatible version of OpenSSL"); return false; } ...
- I tried compiling
-
OpenSSL 1.1 has a backend in Qt since Qt 5.10 but you have to build Qt by hand in order to use it currently.
-
@Pablo-J-Rogina @SGaist that is good to know - would have been useful information on the instructions page that would potentially save developers a lot of time. I might update the wiki with the basic steps for minimum android packaging and deployment (given I find enough time of course).
Thank you all for your help.
-
Hi,
I had a lot of trouble with openssl and qt with android too.
So I wrote a post how to solve the problems.
Hope this helps.@AlfredoC concerning your guide, i have setup a VM so that i could build the apk in ubuntu (i have given up doing it in windows) ubuntu 10.10 runs openssl v 1.1.1. as in your guide says that that wont do, how actually do i use 1.0.2p? can i install it directly? or do i just extract it? im sorry very noob question here.
-
Hi,
I had a lot of trouble with openssl and qt with android too.
So I wrote a post how to solve the problems.
Hope this helps.@AlfredoC hint to your blog post: Qt 5.12 now uses NDK r18b
-
@Alfredo Thank you for the blog post but I'm still having trouble, when I get to the "make depend" part it gives me this error:
"GCC, does not understand command line option "-mandroid""
Based on a google search I'm not using the right GCC, im using (x86) and not the android one in the NDK?Im confused as to how to do this properly.
-
have not tried yet, but this looks great: https://github.com/akontsevich/openssl-android-build
-
have not tried yet, but this looks great: https://github.com/akontsevich/openssl-android-build
This one worked like a charm, took 10 min overall.