NDK does not contain any platforms
Asked Answered
P

10

49

I want to install NDK to be able to use C/C++ native libraries. Upon trying to install the NDK, i get an error saying I do not have enough disk space in my C: Drive (because the download location is to the Temp Folder).

I've tried changing the temp path in the system variables but the ndk still downloads to C:\Users\User\Appdata\Local\Temp\PackageOperation02.

I then went to the project structure to change the Android NDK Location, but upon trying to choose ANY folder to be my NDK location, I get an error saying "NDK does not contain any platforms".

Help for either that or why the download location is to the Temp folder would be appreciated.

Pliers answered 20/5, 2019 at 22:13 Comment(4)
Are you trying to move it to a path that contains spaces? The NDK can't be used from a path that contains spaces.Embarrassment
Spaces in the name? No. The path I want to download the ndk to is E:\TempPliers
This looks like a duplicate of this one: #46742028Cismontane
Does this answer your question? NDK is missing a "platforms" directory. while trying to buildDormouse
R
86

For people seeing this in 2021:

The Android NDK's platform directory has been obsolete since r19. The NDK team removed it altogether in r21 in January 2021. Although it is obsolete, it can still cause the above error in the Project Structure window. The stable version of the Android Studio IDE (at least on Mac) is still looking for the platform directory when you select an r21 or higher version and try to Apply it. The IDE gives the error "NDK does not contain any platforms."

Until Android Studio is updated to stop looking for platform, you can edit the local.properties file yourself, like so:

ndk.dir=/Users/[username]/Library/Android/sdk/ndk/22.0.7026061
sdk.dir=/Users/[username]/Library/Android/sdk

This is what the Project Structure window would normally do for you behind the scenes.

Rockies answered 16/2, 2021 at 22:0 Comment(5)
In my case I wasn't able to change JDK location until I removed ndk.dir from local.properties. As soon as I removed it, I could change JDK location again.Liquid
?this is not working, change this local.properties is just the location for ndk, it looks for platforms as well.Outreach
@Outreach The platforms directory is no longer in the NDK, so there is nothing to look for. You can point to the NDK using the local.properties file instead of using the UI window to circumvent the error.Rockies
@Rockies thanks, yes, ndk 22 dont have platforms, uptodate android studio looks for it, no matter using local.properties or ui window, infact, I cant find the right way to use ndk 22 even now.Outreach
Android Studio will continue to show that error in the Project Structure window, which you can ignore. If it gives you a platform error even when trying to run your app, that would be something to ask as a different question.Rockies
D
7

directory of ndk is now within the sdk folder which is named as ndk and ndk-bundel but the assigning of ndk is now change we need to add ndk version in Android Gradle Plugin (AGP) like this

android {
   ndkVersion "version" // e.g.,  ndkVersion '21.3.6528147'
}

you need also install CMake from SDK tools from sdk manager and need to set is also from the Gradle like below

android {
  ...
  externalNativeBuild {
    cmake {
        ...
        version "cmake-version"
    }
  }
}
Devotion answered 22/12, 2020 at 5:19 Comment(0)
T
3

I got the same problem when I set the NDK dir with something like "SOME_DIRECTORY/ndk".

I resolved this problem by setting it as "SOME_DIRECTORY/ndk/21.0.6113669".

Triley answered 31/3, 2020 at 14:26 Comment(1)
after i download the ndk bundle from SDK Manager , than i choose the directory as ndk/22.0.7026061. and it still have the same problem. And i have try like setting up the path variable or the ndk.dir in local.properties. it sitll like thatGauge
P
3

May be you need an old version of ndk, like android-ndk-r20b. Because I found that there is no platforms directory in unzipped android-ndk-r22 folder. I resolved this issue by configuring Android studio to android-ndk-r20b. Here is the download link https://developer.android.com/ndk/downloads/older_releases

Philemon answered 22/12, 2020 at 5:7 Comment(0)
G
3

As suggested on https://developer.android.com/studio/projects/install-ndk if you are using gradle version above 3.5.0 and uninstall the legacy NDK, you should remove the ndk.dir value, which is now deprecated, from your projects' local.properties files.

Gravimeter answered 30/5, 2021 at 18:34 Comment(0)
R
1

For me the solution was to actually remove the ndk location from local.properties

so

ndk.dir=/Users/[username]/Library/Android/sdk/ndk/22.0.7026061
sdk.dir=/Users/[username]/Library/Android/sdk

would become

sdk.dir=/Users/[username]/Library/Android/sdk
Raspy answered 22/9, 2021 at 10:54 Comment(1)
Specifying the ndkVersion in the gradle and adoption your answer worksSacchariferous
A
1

In my case I am using Windows 11 and Android studio Artic Fox 2020.3.1 patch 2

I tried all above options not working but when I updated my Gradle version it automatically resolved my issue

dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'

Hope this may helpful to someone.

Actually answered 11/11, 2021 at 5:42 Comment(0)
S
0

This is similar to the answer by @YuuY. Since I cannot add a screenshot to comment, I am posting a new answer.

File > Project Structure...> Make sure the directory path includes the version number (e.g. C:\Users...\ndk\21.3.6528147)

enter image description here

Scrouge answered 22/7, 2020 at 3:7 Comment(0)
M
0

I would suggest using the ANDROID NDK REVISION HISTORY

Download the r18b or whatever version suits you, download it manually, and extract it in the SDK folder.

Then go to the project in Android Studio

Edit the local.properties file and add ndk.dir=path-to-sdk/android-ndk-r18b

Meeting answered 5/8, 2021 at 5:52 Comment(0)
G
-2

The Android NDK's platform directory has been obsolete since r19. The NDK team removed it altogether in r21 in January 2021. Although it is obsolete, it can still cause the above error in the Project Structure window. The stable version of the Android Studio IDE (at least on Mac) is still looking for the platform directory when you select an r21 or higher version and try to Apply it. The IDE gives the error "NDK does not contain any platforms."

Until Android Studio is updated to stop looking for platform, you can edit the local.properties file yourself, like so:

sdk.dir=C\:\\Users\\YOUR USER NAME\\AppData\\Local\\Android\\sdk
ndk.dir=C\:\\Users\\YOUR USER NAME\\AppData\\Local\\Android\\sdk\\23.0.7421159
flutter.sdk=C\:\\src\\flutter
Gony answered 21/6, 2021 at 20:39 Comment(1)
Not solving anythingAbbevillian

© 2022 - 2024 — McMap. All rights reserved.