42

My Application is built successfully on Eclipse but fails to Build on android studio. It returns the error code Ndk is not Configured. Then I've added ndk path to build.gradle then its showing the following error:

Information:Gradle tasks [:nano:assembleDebug]
WARNING [Project: :nano] Current NDK support is deprecated.  Alternative will be provided in the future.
:nano:preBuild UP-TO-DATE
:nano:preDebugBuild UP-TO-DATE
:nano:compileDebugNdk
make.exe: *** No rule to make target `C:\Users\admin\nano\nano\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/la_audio_processing_android/C_\Users\admin\nano\nano\src\main\jni', needed by `C:\Users\admin\nano\nano\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/la_audio_processing_android/C_\Users\admin\nano\nano\src\main\jni\LA_PostProcessing.o'.  Stop.
Error:Execution failed for task ':nano:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\admin\AppData\Local\Android\ndk\ndk-build.cmd'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 3.449 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
Leandro Carracedo
  • 7,233
  • 2
  • 44
  • 50

9 Answers9

53

This is the problem faced by Android studio users in Windows environment. First for NDK not Configured problem

Go to local.properties file and give ndk path... for ex :

#Wed Mar 18 14:10:33 IST 2015
sdk.dir=C\:\\Users\\admin\\AppData\\Local\\Android\\sdk1
ndk.dir=C\:\\Users\\admin\\AppData\\Local\\Android\\ndk

Then for the Next Problem or Error...

Goto JNI Folder and create an empty c file by any name... Then your problem will be solved...

Some Quick links about this are http://ph0b.com/android-studio-gradle-and-ndk-integration/ And https://code.google.com/p/android/issues/detail?id=66937

  • 1
    A Linux Mint 17 problem as well. – Zon Apr 11 '17 at 03:54
  • 3
    my local.properties looks like this on osx (Android Studio) - Flutter Project: `sdk.dir=/Users/USERNAME/Library/Android/sdk` `ndk.dir=/Users/USERNAME/Library/Android/sdk/ndk` – zanuka Oct 01 '19 at 04:18
  • 1
    and this when using older NDK version `ndk.dir=/Users/USERNAME/Library/Android/sdk/ndk-bundle` – zanuka Oct 01 '19 at 04:43
37

Go to option File->Project Structure

enter image description here

Select SDK Location->Android NDK Location and choose NDK listed in dropdown

enter image description here

Shiv Buyya
  • 3,770
  • 2
  • 30
  • 25
15

For whatever reason, setting ndk.dir on the properties file is not working for me. However, setting/exporting the variable ANDROID_NDK_HOME prior to launching android studio did the trick.

Bash syntax (paths below are specific to my installation)

export ANDROID_HOME=/opt/android-sdk-linux
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle

Environment

Ubuntu Linux x64/GNU bash, version 4.4/Android Studio 2.2.3
Keo Malope
  • 1,015
  • 12
  • 19
12

Goto Files -> Project Structure -> SDK Location

Android NDK Location is at the bottom right of the window.

Cletus Ajibade
  • 1,550
  • 15
  • 14
9

I use Android Studio 1.4.1.

Below is my local.properties

ndk.dir=C:\Users\BestQ\AppData\Local\Android\Sdk\ndk-bundle sdk.dir=C:\Users\BestQ\AppData\Local\Android\Sdk

It work well.

8

In build.gradle use

android {
  ndkVersion '21.1.6352462' 
}

and use android.useDeprecatedNdk=true in gradle.properties

Benjamin
  • 1,143
  • 1
  • 14
  • 29
3

In some cases, you need to point exact version of ndk version on the local.properties file like that:

ndk.dir=/Users/ali6p/Library/Android/sdk/ndk/21.3.6528147

If you need to install a specific version of ndk bundle, open Android Studio preferences and install the version (Preferences > Appearance & Behaviour > System Settings > Android SDK > SDK Tools: Show Package Details > NDK (Side by side): check the version:

Android studio preferences to install ndk version

ali6p
  • 1,683
  • 13
  • 17
0

My issue was caused by the target file not being found (in my case, a git sub-module needed to be checked out), so ensure all the referenced files exist on the specified path.

TheIT
  • 11,919
  • 4
  • 64
  • 56
0

Maybe the NDK is not installed. If it's the case, go to SDK Manager (top-right icon). Go to Android SDK > SDK Tools Check NDK (Side by side) and install it.

enter image description here

Florian K
  • 2,033
  • 1
  • 9
  • 21