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

2

8

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. :)

Superheat answered 27/9, 2019 at 7:18 Comment(0)
G
11

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.

Ghastly answered 27/9, 2019 at 11:43 Comment(4)
OK, that sounds nice, but I need the version back to 11b. As far as I can see, there's only Version 20.0.5594570 available for side-by-side. Am I missing something? By trying your solution i get this error: No version of NDK matched the requested version 19.2.5345600. Versions available locally: 20.0.5594570, 20.0.5594570Superheat
As I wrote, you must go an extra mile to call SDK Manager so that it downloads the missing version for you. But this is not relevant for r11b. You can rely on the same directory structure to wget https://dl.google.com/android/repository/android-ndk-r11b-linux-x86_64.zip and unzip it there. But you have a bigger problem: r11b is not compatible with the externalNativeBuild.Ghastly
BTW I think the need to manually download them is fixed in 3.6. IIRC there will be a quickfix that you can click if you try to build a project that uses an NDK you don't have (not auto-downloading because nobody likes surprise 1GB downloads).Lenssen
Sharing local.properties does help if an NFS shared storage stores the NDK and mounted by each machine.Fatality
W
0

WARNING: Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead. Support for ANDROID_NDK_HOME is deprecated and will be removed in the future.

> Use android.ndkVersion in build.gradle instead.
Werby answered 10/10, 2022 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.