Android Studio says the NDK is not configured or cannot be found
NDK is not configuredShort answer
The Android Gradle plugin needs an NDK it can find. Either none is installed, the version in ndkVersion is not the one on disk, or an old ndk.dir line in local.properties points somewhere else. Install the NDK in SDK Manager, then set ndkVersion to an installed version and delete ndk.dir.
Fix it fast
1Find out which cause you have
List what is installed under the SDK. NDK versions live in the ndk folder, one subfolder per version.
ls "$ANDROID_HOME/ndk" grep -n "ndk" local.properties app/build.gradle*2Match what you see, then jump to its fix
- 1
The ndk folder does not exist or is emptyNo NDK is installedFix - 2
Gradle asks for a specific NDK version and your ndk folder holds anotherndkVersion names a version that is not installedFix - 3
local.properties still contains ndk.dir, from the legacy ndk-bundle folderAn old ndk.dir line in local.properties points to a removed NDKFix
- 1
What does the error look like?
NDK is not configuredNative build fails with no NDK installed or the wrong NDK version
Cause 1 of 3
No NDK is installed
1Check
In Android Studio open Tools > SDK Manager > SDK Tools and see whether NDK (Side by side) is ticked.
ls "$ANDROID_HOME/ndk"2Fix
Tick NDK (Side by side) and CMake and press OK. The same can be done from the command line. Android Gradle plugin 4.2 and newer can also download the NDK on the first build, but only if the SDK licences were accepted before.
yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses
"$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --install "ndk;major.minor.build"3Verify
Sync the project. A version folder now exists in the ndk directory.
ls "$ANDROID_HOME/ndk"Confirmed by developer.android.com
Cause 2 of 3
ndkVersion names a version that is not installed
1Check
Compare the version in the module build file with the folder names under the ndk directory.
grep -n "ndkVersion" app/build.gradle app/build.gradle.kts
ls "$ANDROID_HOME/ndk"2Fix
Install the version the file asks for (Show Package Details in SDK Manager), or change ndkVersion to one you have. If you set no version, the plugin picks the NDK version it was tested with.
android {
ndkVersion = "major.minor.build" // exactly a folder name under sdk/ndk
}3Verify
Sync the project; the native task starts.
./gradlew assembleDebugConfirmed by developer.android.com
Cause 3 of 3
An old ndk.dir line in local.properties points to a removed NDK
1Check
The docs mark ndk.dir as deprecated. If you uninstalled the legacy NDK, the value is stale.
grep -n "ndk.dir" local.properties2Fix
Delete the ndk.dir line. Use ndkVersion for a side by side NDK, or ndkPath for an NDK in a custom place (leave ndkPath out of version control).
# local.properties: remove this line
# ndk.dir=/old/path/ndk-bundle
android {
ndkPath = "/path/to/your/ndk" // only if you need a custom location
}3Verify
Sync the project again.
./gradlew assembleDebugConfirmed by developer.android.com
How do I stop it coming back?
- Pin ndkVersion in the module build file so every machine builds with the same NDK.
- On a CI machine, accept the licences in the image build with sdkmanager --licenses.
- Do not commit local.properties.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
Android Gradle cannot find the CMake version your module asks for
The native build task fails before any C or C++ file is compiled
Gradle looks for the CMake version your module names, or 3.10.2 when no version is set, and found none.
3 causes, each with a fixMobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fix