I am trying to build an Android project with Gradle. The project uses native code and thus needs NDK, which I have installed.
However, Gradle fails with the following error:
> NDK not configured.
Download it with SDK manager.
Android’s SDK Manager does not list NDK as an option. Besides, I have NDK installed on my box, so the error seems to be that Gradle isn’t finding it.
Most answers assume users to have Android Studio, which I do not have and do not want. Any way to fix this without?
Yes, you don't have to install Android Studio. For your existing Android project, I expect that you already have local.properties under your root dir of your project. Open and modify there to set your NDK dir.
To install a specific version of the NDK, do the following: With a project open, click Tools > SDK Manager. Click the SDK Tools tab. Select the Show Package Details checkbox.
Step 1: Installing NDK and CMAKE SDK tool from android studios (You can skip it, if already installed) 1 Click OK. 2 A dialog box tells you how much space the NDK package consumes on disk. 3 Click OK. 4 When the installation is complete, click Finish. 5 Now, rebuild your app. It should work fine now. More ...
Android’s SDK Manager does not list NDK as an option. Besides, I have NDK installed on my box, so the error seems to be that Gradle isn’t finding it. Most answers assume users to have Android Studio, which I do not have and do not want. Any way to fix this without? Show activity on this post.
Most answers assume users to have Android Studio, which I do not have and do not want. Any way to fix this without?
Yes, you don't have to install Android Studio.
For your existing Android project, I expect that you already have local.properties
under your root dir of your project. Open and modify there to set your NDK dir. For example, your NDK version is android-ndk-r17b (https://developer.android.com/ndk/downloads/), and you have installed (or unzipped) it in directory /Users/myname/foo/xxx/Android/android-ndk-r17b
, then modify this file as below:
ndk.dir=/Users/myname/foo/xxx/Android/android-ndk-r17b
sdk.dir=/Users/myname/foo/xxx/Android/sdk
Make sure you have an environment variable ANDROID_NDK_HOME
set and pointing to your NDK install directory. In my case this did the trick:
export ANDROID_NDK_HOME=/home/myself/bin/android-ndk-r10e
You may want to add this to your .bashrc
or similar to have the variable inserted at login, or run the command above each time you launch a shell and want to build an NDK project.
As an alternative, if you installed ndk-bundle
through sdkmanager
, it will be found without an extra environment variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With