Search code examples
androidandroid-ndk

Will upgrading NDK upgrade the Android system's zlib version?


Suppose I have a CMakeLists.txt to build an Android library with native C++ code:

find_library(
        zlib
        z
)

The zlib library should be a prebuilt library provided by the Android system, I'm wondering if we can upgrade the zlib version (for example from 1.2.11 to 1.2.13) via upgrading our NDK tool version?

This confuses me a lot because it is said that the zlib library is prebuilt and located on the Android device. Besides, I checked my library artifact, I didn't find the zlib.so included.


Solution

  • No. The zlib library is built into the Android OS, you link against the version included by the device. However, you could add a compiled version of zlib to your app and link to it explicitly. That would bloat the size of your apk file by the size of that .so file, and it would prevent you from getting additional updates in the future unless you update it in your app.