androidandroid-ndkndk-buildjitpack

NDK: Is it possible to define the android NDK Version in build.gradle so the native code will use a defined version?


Here's my problem:

I've got a library stored at Github. That Library contains native code and everything that's needed for handling C++ files. Locally the project/library works fine but I want to include that library as a dependency via JitPack. So that's where the problem starts...

JitPack seems to use the newest version of NDK but that's not the version my code can be built with. For now, there's no time to update my library but can't find any solution to define the NDK version as a dependency to the project.

I know that ndk.dir can be defined at local.properties but that file should not be part of the repo. I wonder if there's a way to tell JitPack which NDK-Version it should use to build the dependency.

I'm curious if any of you already had a similar problem and if anyone has an idea how to solve it.

I appreciate any idea. :)


Solution

  • Today, Android Studio plugin supports side-by-side NDK, and the SDK Manager can manage multiple versions of NDK. In gradle.build, you set e.g. android.ndkVersion '19.2.5345600'. You can probably trigger SDK Manager programmatically to install the expected version.

    Note that sharing local.properties would not help, because it points to NDK installed directory (which depends on the PC configuration), and does not store the NDK version.