Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the exact significance of Android NDK platform version compared to API level?

I have an Android app with minSdkVersion.apiLevel set to 18 targetSdkVersion.apiLevel set to 23. Accordingly I set the NDK platformVersion to 18.

Unfortunately after adding OpenSSL to the mix, the JNI library now fails to link:

/Users/pol/Downloads/Cross/External/Android-Libraries/openssl-1.0.2g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
/Users/pol/Downloads/Cross/External/Android-Libraries/openssl-1.0.2g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/Users/pol/Downloads/Cross/External/Android-Libraries/openssl-1.0.2g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/Users/pol/Downloads/Cross/External/Android-Libraries/openssl-1.0.2g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'

The problem goes away if setting platformVersion to 21 (it doesn't work either at 19).

What does this mean for the Android app if it has an API level of 18 but the JNI library was linked for 21? Will it crash at launch on a device running 4.3?

I cannot imagine the signal symbol be missing from 4.3 though. Is this an NDK bug?

like image 374
Pol Avatar asked May 09 '16 17:05

Pol


1 Answers

This is exactly what will happen to your shared library when you install it on android-20 or earlier: it will fail to load. You should not be surprised that signal was missing: Android runtime was never intended to run command-line tools like curl.

like image 104
Alex Cohn Avatar answered Oct 03 '22 23:10

Alex Cohn