Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDK not configured (although it is installed)—how to fix without Android Studio

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?

like image 718
user149408 Avatar asked Jul 19 '18 22:07

user149408


People also ask

Do I have to install Android Studio to install NDK?

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.

How do I install a specific version of NDK?

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.

How to install NDK and CMake SDK for Android?

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

Does Gradle not find NDK in Android 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? Show activity on this post.


Video Answer


2 Answers

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
like image 54
shizhen Avatar answered Sep 17 '22 15:09

shizhen


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.

like image 24
user149408 Avatar answered Sep 21 '22 15:09

user149408