'ModelCache.safeGet(androidProjectResult.androidProject::getNdkVersion, "") must not be null

When I Updated the Android Studio to the Bumblebee 2021.1.1 I got this error:

ModelCache.safeGet(androidProjectResult.androidProject::getNdkVersion, "") must not be null

I have already added ndk.dir to local.properties but I still have the error.

sdk.dir=/path/to/sdk
ndk.dir=/path/to/ndk


Solution 1:[1]

enter image description here

Add ndk path in android.ndkPath

Or

Add ndkVersion '23.0.7599858' (If you use this approach then in some case you have to add version in other library module if they use ndk)

enter image description here


You can also add this using File-> Project Structure

Project Structure

Solution 2:[2]

The value for ndk.dir should no longer be set in your app's local.properties file, and support for this ndk.dir setting will be removed in a future version. The Android Gradle Plugin sets the NDK version by default, but if you need a specific version of the NDK, you can set android.ndkVersion in build.gradle.

  1. Remove ndk.dir=/path/to/ndk from the local.properties.
  2. go to build.gradle under android section add ndkVersion='required ndk version'

ex:

android {

ndkVersion '23.1.7779620'

}

Reference : Android office doc's

Solution 3:[3]

ndk.dir=/path/Android/Sdk/ndk
sdk.dir=/path/Android/Sdk

Try to define like this

Solution 4:[4]

Follow these two steps to solve the issue

  1. Go to SDK Manager>SDK Tools> NDK > Uninstall all

  2. Go to the ndk directory and see if it's empty, If it is not, delete the files

  3. Install a new copy of ndk from SDK manager

  4. in your local.properties gives your path as

sdk.dir=D\:\\AndroidFiles
ndk.dir=D\:\\AndroidFiles\\ndk\\23.0.7599858

Solution 5:[5]

Google has provide this fix in Android Studio Bumblebee | 2021.1.1 Patch 2 (Issue link)

So, updating my Android Studio to Bumblebee patch-2 solved this error. Now I need not to add the ndk paths as suggested in other answers.

Google Android Studio changelog

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bhavin Patel
Solution 2 Zoo Zoo
Solution 3 Santhosh PR
Solution 4 Narendra_Nath
Solution 5 Astha Garg