Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK - Using libraries compiled with a different API level

I have a group of C/C++ libraries compiled with a standalone toolchain for API 19 and NDK rev 17, is it be possible to use these libraries on a project that uses API 26 (min SDK target 19)? Or do I need to recompile them using API 26?

In the script, make_standalone_toolchain.py ask for the --api argument but I am unsure if this is supposed to be the minimum API or the target API used on the project.

like image 546
IzonFreak Avatar asked Jul 06 '26 14:07

IzonFreak


1 Answers

Yes, it is okay to mix and match libraries with different minSdkVersions (the only SDK version that is relevant to the NDK). This is actually the default configuration whenever you target something other than the NDK's minimum supported API level, because the C++ standard library is built against the minimum supported version.

The only thing you need to keep in mind is that the highest minSdkVersion is the minSdkVersion for the whole app. If you have a library built for 19 and a library built for 28, the oldest Android version that app will run on is 28.

(To be clear, that is per-ABI. If you target 21 for 64-bit and 16 for 32-bit, the 32-bit app can still be run on 16.)

like image 121
Dan Albert Avatar answered Jul 09 '26 05:07

Dan Albert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!