I am completely new to Android development and just installed Android Studio. I'm doing a very basic HelloGL2 exercise, and I opened up the HelloGL2.iml file. I tried running it, but it said that the gradle project sync failed and that the NDK is not configured. In the simplest terms (to a complete beginner in Android), how do I fix this?
-
I'm going to assume you've found this code lab: https://codelabs.developers.google.com/codelabs/android-studio-jni/#0 which step-by-step answers how to get 'Hello World' working with Android Studio and the NDK. – Morrison Chang Dec 03 '16 at 04:41
-
3Can't post an answer, but for anyone who's running an unconventional setup and might need to provide paths manually: ANDROID_NDK_HOME = "YOUR_PATH_TO_LOCATE_NDK_BUNDLE", where the path should be something like /path/to/Sdk/ndk-bundle – Apr 20 '18 at 06:52
14 Answers
disclaimer: I work on Android Studio
With newer version (3.6+) of Android Gradle Plugin, please download with "NDK (Side by side)" option from the SDK manager and then specify ndkVersion
in the build.gradle
with the full version of NDK that is locally available from your machine.
For example, after you downloaded NDK 20.1.5948944 under "NDK (Side by side)" from the SDK manager, the downloaded NDK would be, by default, under ~/Android/Sdk/ndk/20.1.5948944
. Then in your module level build.gradle
, you need something like the following.
android {
compileSdkVersion 29
defaultConfig {
// ...
}
buildTypes {
// ...
}
externalNativeBuild {
// ...
}
ndkVersion "20.1.5948944" // <<==== Here
}

- 1,768
- 2
- 15
- 20
-
1Thank you! I was still getting an error because the version the SDK manager downloaded was different than the one specified in the project I tried to open. Changing the ndkVersion in the build.gradle to match the one on disk fixed the error for me. – Izabela Orlowska Jan 22 '20 at 11:50
-
Fixed it for me too, so thank you! It's a pity the Android Studio does not handle this automatically, while it does for a lot(!) of other things. – fredvanl Feb 27 '20 at 12:33
-
Why does it ask me for NDK in a project where NDK is not needed or used? Will this force all who work on project to download and sync NDK version requested by AS? – Chapz Mar 02 '20 at 07:53
-
Hi @Chapz I am not able to reproduce the issue on a fresh machine (no NDK installed) with AS and AGP 3.6.1. Could you [file a bug](https://developer.android.com/studio/report-bugs#studio-bugs) with more detailed information? – tgeng Mar 02 '20 at 17:57
-
-
@protossor I could reproduce this with latest version of everything and the sample android c++ project in android studio. it worked after putting in the line with the `ndkVersion`. thanks! – Niklas Rosencrantz Mar 03 '20 at 10:55
-
Hi @grrigore, could you [file a bug](https://developer.android.com/studio/report-bugs#studio-bugs) with more detailed information? – tgeng Mar 12 '20 at 20:05
-
Hello @protossor, I managed to make it work, however, it was necessary to uninstall NDK, CMake and LLDB and reinstall them. Also some `Invalidate caches and restart` were involved. – grrigore Mar 13 '20 at 07:48
-
> Could not find method ndkVersion() for arguments [20.1.5948944] on object of type com.android.build.gradle.AppExtension. – Isaac Urbina Mar 18 '20 at 16:37
-
-
@protossor I had to install the NDK (obsolete) from SDK Manager and then it worked without adding the ndkVersion in gradle – Isaac Urbina Mar 19 '20 at 20:39
-
Hi @IsaacUrbina, it sounds like you are using an old version of Android Gradle plugin (specified in your top level `build.gradle` file). `ndk-bundle` is deprecated and will be removed in future. – tgeng Mar 19 '20 at 21:00
-
PS It worked by specifying the path of ndk as mentioned, but in build.gradle I just commented out the ndk.version... – giorgio79 Mar 19 '21 at 12:15
-
I don't know if you still work on Android Studio, but just a quick feedback, it would be REALLY good if there was a good documentation about where and how the NDK should be setup, since there are so many differences between different AGP versions... – Bernardo do Amaral Teodosio Apr 28 '23 at 20:19
-
Hi I no longer work on this. Can you [file a bug](https://developer.android.com/studio/report-bugs#studio-bugs)? – tgeng Apr 28 '23 at 20:50
I double-checked that I already had the latest NDK installed (so that wasn't the solution for me). Next I did the following: Android Studio Menu -> File -> Project structure -> SDK Location. Here, no NDK was selected, so I selected the latest version. This solved the problem.
This fix only works locally for this particular machine and for this project by writing your choice to the local.properties
file in your project's root.
UPDATE: There's also a way to set this globally via ANDROID_NDK_HOME
environment variable. This is how I invoke building my project on a build server:
export ANDROID_SDK_ROOT=/home/jenkins/Android/Sdk/; export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.0.6113669; ./gradlew assembleRelease

- 32,368
- 48
- 194
- 335
-
1This should be the right answer because SDK manager wasn't available when this error was happening. I had to select the default NDK path and it worked fine for me. This is Android Studio version 3.6.2. – Karthik Kannan May 26 '20 at 15:35
You can install these components using the SDK Manager:
- From an open project, select
Tools > Android > SDK Manager
from the main menu. - Click the
SDK Tools
tab. - Check the box next to
NDK
,CMake
, andLLDB
- Click
apply
(Using Android Studio 3.6.1)
Edit: Following above process on later versions of Android Studio still gives an NDK not installed
error during the build process. This answer given by Violet Giraffe solved the issue. Once the necessary files are installed, go to File > Project Structure > SDK
and select the NDK version.
See this guide for more details.

- 808
- 3
- 14
- 31

- 638
- 1
- 5
- 11
-
7
-
@Pacu I wrote it in 2016. Are instructions correct? I do not have android studio installed on my machine currently. – Umair Jan 17 '20 at 15:32
-
The instructions to reach the menu are ok, but checking NDK, does not fix the issue – Pacu Jan 22 '20 at 15:04
-
-
For above Android Studio 4.0, paste this in local.properties
:
ndk.dir=C\:\\Users\\USER\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147
For Mac Users, paste this in local.properties
:
ndk.dir=/Users/USERNAME/Library/Android/sdk/ndk/23.1.7779620

- 3
- 3

- 450
- 7
- 9
-
1Just make sure your folder name under ndk folder matches. In my case it was 25.2.9519653. – makkuzu Jun 16 '23 at 04:13
worked !!
- Go to SDK manager > android sdk(left side) > SDK Tools
- download or if availble then update to NDK(side_by_side) and CMake
3. now, do OK or Apply 4. Get back and click on "Install NDK '21.0.6113669' and sync project" in your failed build.
Happy coding :)

- 319
- 3
- 4
I ran into this error while trying to run SQLite Android Bindings. It still uses a very old gradle configuration (included below).
TLDR
Please take protossor
's advice and use NDK (Side by side)
and set an ndkVersion
in your build.gradle
. Only use this on very old projects.
For old projects, you must install the obsolete NDK from the SDK manager. In Android Studio, open the SDK Manager
and choose the SDK Tools
tab. Uncheck Hide Obsolete Packages
, and then scroll to the bottom to find NDK (Obsolete)
.
More Details
I ran ./gradlew assembleRelease
per the instructions, and I got the following:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':sqlite3'.
> NDK not configured.
Download it with SDK manager.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
I got a similar error in Android Studio when it attempted to configure the project. After I installed the NDK (Obsolete)
package, everything configured properly.
SQLite
's woefully out of date gradle
configuration:
$ROOT/build.gradle
:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
$ROOT/sqlitetest/build.gradle
:
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}

- 30,998
- 16
- 147
- 256
//Try this one 1 - Android Studio -> Tools -> SDK Manager -> select SDK Tools
2 - Check the boxes next to LLDB, CMake, and NDK

- 61
- 2
- 1
with android studio 3.0 + this issue is approached differently.
Go to File > Settings > Android SDK > and select the SDK entry and update. It should fix the issue.
the other approach to the same problem is when you do a gradle project sync it will automatically identify the issue of requiring version upgrade and provide you clickable link in the console. Through these steps it might also prompt you to update other dependencies, such as CMake.

- 1,030
- 13
- 37
open android->local.properties (If this file is not exist, create local.properties file in android folder) and add
ndk.dir=/Users/{{username}}/Library/Android/sdk/ndk-bundle #in mac
ndk.dir=C:\\Users\\{{username}}\\AppData\\Local\\Android\\sdk\\ndk-bundle #in Windows
Check ndk-bundle folder is exists in android sdk folder. Otherwise install the ndk(side by side) using sdk manager in android studio then rebuild the app
ANDROID STUDIO -> tools -> SDK manager -> SDK tools -> ndk (side by side)
or
ANDROID STUDIO -> preferences -> appearance & behavior -> system settings -> android SDK -> SDK tools -> ndk (side by side)

- 1,901
- 20
- 23
if you see this error you may have not any NDK in your SDK.
so you better download it from hereand copy all folders and files in your SDK.
also you can go; open project>select tools[in upper page]>Android>SDK Manager[from main menu]>click SDK Tools tab>and check the box next to NDK
if you have not NDK in SDK Tools tab,you can download automatic in this folder

- 228
- 3
- 9
NDK(side by side) 21.x.xxxxx is the key to solution.
Go to the SDK tools as mentioned in above/other answers, then you may need to experiment with ndk version.
Click show package details to know what versions are available.
Also, you may need to add something like this in the local.properties
. Like
ndk.dir=/home/username/Android/Sdk/ndk/21.x.xxxxx
PS: you may also need to upgrade the gradle plugin depending upon which version you are using
My env: MAC M1

- 61
- 2
-
This answer worked for me. I could not select an NDK version from the project structure menu, and it *looked like* the NDK was already installed in the SDK manager. It wasn't until i used the "Show Package Details" checkbox that i realized that the installed NDK version was different than the one in my build.gradle file. :-/ Thanks! – jetsetter Sep 10 '21 at 17:18
For Linux:
Create file local.properties
:
ndk.dir=/home/username/Android/Sdk/ndk/21.3.6528147
Now close the project and import it again.
-
1Warning: `NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please delete ndk.dir from local.properties and set android.ndkVersion to [20.0.5594570] in all native modules in the project.` – mazunki Mar 23 '21 at 10:23
My version is a little bit different :
From an open project, select Tools > Android > SDK Manager from the main menu. In Appearance & behavior > System Settings > Android SDK I have to Click the SDK Tools tab. Check the box next to NDK Click apply

- 285
- 1
- 7
Make sure you add the version which is mentioned in SDK manager in your gradle.build file under android directory like this.
android { ndkVersion "25.1.8937393" // whichever version you have in SDK manager. }

- 459
- 1
- 8
- 15