How to fix android studios 2.3 NDK bug?

I'm assuming it's a bug since I didn't have any problems until the new update. So I cant use the gradle console to debug my app because I have this warning -

"Configuration on demand is an incubating feature. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Emily Thacker\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning."

I am pretty sure I am not using NDK and I dont see how I can fix this problem here is my local.properties

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:\\Users\\Emily Thacker\\AppData\\Local\\Android\\Sdk

Also I do not see a ANDROID_NDK_HOME file in my directory.


I was able to prevent this annoying message; here is what worked for me.

BACKGROUND:

  1. I am not using the NDK at all, and had never installed the NDK.

  2. However, as mentioned in another answer here by xsveda, this is a Gradle bug that is documented here:

    https://code.google.com/p/android/issues/detail?id=228424

    and so even the "NDK-innocent" may become its victims.

  3. The problem is that Gradle is computing the location of an NDK folder by just tacking on the string "/ndk-bundle" to the SDK folder location, even if you have never installed the NDK.

  4. After establishing this false expectation of an NDK folder existing in a particular location, each time you build, Gradle gives you a warning that you're "missing" that folder. This is just a warning and does not prevent your build from completing, but it is annoying.

HOW I STOPPED THE ANNOYING MESSAGE:

Since disk space is cheap, and my time is precious to me, I humored this bug by installing the NDK, even though I do not intend to use it.

To do this, you can go to:

File -> Project Structure -> SDK Location

and look in the Android NDK location field. If you have not installed the NDK, this field will be empty.

In that case, below that field will be a link for installing the NDK. Click on that link and install it. It takes a few minutes.

Once the installation completes and you close the installation progress dialog, the location of the NDK will be automatically written into the Android NDK location field. This will be something like:

C:\dev\astudiosdk\ndk-bundle

Click the OK button and build again. The error disappears.

Note that you may be able to just type the expected folder into this field; I did not try that. But I don't know whether that might cause some other problems, especially if you eventually decide to actually use the NDK.


Just install the Android NDK.

That fixed my error and warning!

https://i.stack.imgur.com/Lsu8E.png

  1. Go to Tools -> Android -> SDK Manager
  2. Click SDK Tools
  3. CHECK NDK
  4. Apply and quit.

Fixed this issue by removing an empty ndk-bundle folder from SDK root folder (have no idea why and when it has appeared):

ndk-bundle folder in android SDK folder

Here is the explanation why it helps from the issue on Android bug tracker:

For anyone still experience this issue on plugin 3.0.0-alpha1 or later. Please file a new bug and try to answer all question in #33. We need more information to debug the problem and adding comments to a closed bug is an easy way for it to get lost.

To give a bit of background, the plugin checks whether the NDK directory is valid. Most likely, you are not using NDK. We automatically assume it's in {sdk}/ndk-bundle. It will be ignored if {sdk}/ndk-bundle does not exist. If you see 'NDK is missing a "platforms" directory.', it means there is an {sdk}/ndk-bundle, but not a {sdk}/ndk-bundle/platforms directory. This means you have a corrupted NDK for some reason. It is safe to just remove {sdk}/ndk-bundle if you are not using it.


I faced this problem:

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/<user_name>/Library/Android/sdk/ndk-bundle.

and I solved it by creating one empty platforms folder in ndk-bundle folder. Like: path/to/your/Android/sdk/ndk-bundle/platforms.

In case you do not have ndk-bundle folder. Install NDK by following steps (Install NDK screenshot) :

  • Open Preferences
  • Go to Android SDK from left menu.
  • Select SDK Tools.
  • Check NDK.
  • Apply and OK.

Gradle version: 6.3

Android studio version: Android Studio 4.1.1 Build #AI-201.8743.12.41.6953283, built on November 5, 2020

PS: I did manual installation of gradle from: https://docs.gradle.org/current/userguide/installation.html


Sounds like maybe updating SDK from Android Studio IDE could help

Steps are:

  1. Go to Tools (top-menu item) > Android > SDK Manager
  2. Click SDK Tools tab
  3. Scroll down to the NDK checkbox update-option

Screen shots here: How to update Android NDK in place?