7

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

NPovlsen
  • 337
  • 1
  • 16
Thomas Cirksena
  • 717
  • 2
  • 8
  • 28

2 Answers2

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.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • 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.5594570 – Thomas Cirksena Sep 27 '19 at 12:04
  • 1
    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`. – Alex Cohn Sep 27 '19 at 13:40
  • 1
    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). – Dan Albert Sep 27 '19 at 19:45
  • Sharing `local.properties` does help if an NFS shared storage stores the **NDK** and mounted by each machine. – daparic Aug 18 '21 at 11:08
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.
Kareem Alsaifi
  • 399
  • 4
  • 11