Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Android Studio says the NDK is not configured or cannot be found

ErrorNDK is not configured

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

  • Applies to Android Studio current stable, Android Gradle plugin 8.x, NDK side by side
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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*
  2. 2Match what you see, then jump to its fix

    1. 1The ndk folder does not exist or is emptyNo NDK is installedFix
    2. 2Gradle asks for a specific NDK version and your ndk folder holds anotherndkVersion names a version that is not installedFix
    3. 3local.properties still contains ndk.dir, from the legacy ndk-bundle folderAn old ndk.dir line in local.properties points to a removed NDKFix

What does the error look like?

  • NDK is not configured
  • Native 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

Did this fix it?

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 assembleDebug

Confirmed by developer.android.com

Did this fix it?

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

2Fix

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 assembleDebug

Confirmed by developer.android.com

Did this fix it?

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.