34

My ndk is located at C:\Users\X\AppData\Local\Android\ndk. Now each time I create a new native android project and try to import into Android Studio, it asks me for the location of ndk. I can manually set the ndk in local.properties also.

But I am looking for a way to set this ndk path, so that Android Studio does not ask me to set this path each time.

I have already set ANDROID_NDK_HOME, as well as NDK_HOME in system environment variable on Windows 10 machine, but Android Studio is still not able to find it. I have restarted my machine as well, still no luck.

I have not tried it on mac, but your answers for both windows and mac are welcome.

7
  • set sdk and ndk path in local.properties file
    – Sabish.M
    Aug 26, 2016 at 6:10
  • 2
    @Sabish.M: I know how to do that. But I have to do it for each new project manually. I want to tell Android Studio, ndk path just once, so that I don't have to specify it again. Aug 26, 2016 at 6:13
  • 2
    I believe its ANDROID_NDK_ROOT, not NDK_HOME. File a bug report against Android Studio if you are following the advice at ndk-build and command not found using eclipse mac and setting ANDROID_NDK_ROOT.
    – jww
    Aug 26, 2016 at 6:25
  • 2
    @jww: Thanks, I tried ANDROID_NDK_ROOT, but that's not working either. BTW I am trying on windows machine currently. I am yet to try on mac. Aug 26, 2016 at 6:46
  • 2
    @VinayakGarg - File a bug report. Those variables and practices have been around for years. There's no reason for Android Studio to disregard instructions or create ad hoc procedures. It will save developers that follow time and effort.
    – jww
    Aug 26, 2016 at 6:51

7 Answers 7

19

1.Check the NDK Path. Select the menu File > Project Structure > SDK Location, Android NDK Location if it is not set yet, then click ..., and browse to your NDK location and click "OK" (you may also choose "download").

Snapshot for locating the above

2.To have it edit the local.properties file of your project

ndk.dir = YOUR_NDK_PATH

Set a Environment variable for your system

ANDROID_NDK_HOME = "YOUR_PATH_TO_LOCATE_NDK_BUNDLE"

default if you downloaded from SDK manager then it will be

"YOUR_SDK_PATH/android-sdk-windows\ndk-bundle"

Once you set once. If will by default use the settings for Ndk location for the all your android projects too.

5
  • @VinayakGarg Yes . Your NDK path should be "YOUR_SDK_PATH/android-sdk-windows\ndk-bundle" . The studio versions prior to 2.2 uses the defined path only. If you give different path it will not take it whether or not you NDK_HOME is set in environment variable. When you download from SDK manager-->NDK , then the default path would be the above one which is accepted by later versions of android studio
    – Arpit Garg
    Aug 26, 2016 at 7:03
  • 1
    I don't think you understand. We both don't have nor plan to download NDK. How can we get rid of the message "NDK is missing a platforms" directory"?
    – yes4me
    Jun 20, 2017 at 7:23
  • 2
    OP is asking how to set the path when there is no project is loaded. this way is expecting to be able to use the path for all new projects regardless if he want to use NDK in his app or not. the option you mentioned is disabled if no project is loaded.
    – AaA
    Jul 11, 2017 at 8:48
  • Just installed it from the SDK manager it was set to C:\Users\myuser\AppData\Local\Android\Sdk\ndk\20.0.5594570
    – WindRider
    Aug 19, 2019 at 12:28
  • yes changing path to default ndk in android sdk package accepted thanks for the answer Feb 10, 2020 at 9:58
5

Set ndk folder location in local.properties file

ndk.dir=C:/Users/{username}/AppData/Local/Android/Sdk/ndk/21.3.6528147

Happy Fluttering ....

5

I didn't use ndk-bundles in my Project, but got this issue anyway.

I solved it like this: Go to your sdk.dir (maybe have a look into local.properties).

If you don't use ndk, you shouldn't see an /ndk-bundle directory. If it's appear in your /sdk-Directory, look into it (should be emtpy).

Remove this ndk-bundle folder

After that, my error-messages are gone.

1
  • After many hours try., apply your solution working. Have for the day.
    – Hemantvc
    Mar 17, 2022 at 12:37
3

enter image description hereFile->Project Structure set your sdk and ndk location in here.

4
  • 2
    There is a field to set sdk location, but not for ndk. Just to clarify, I am looking for a global solution, that works for all new projects, not just current project Aug 26, 2016 at 6:16
  • I am using Android Studio 2.1.3, and I have a different Project Structure screen. Aug 26, 2016 at 6:48
  • 3
    Using android studio 2.2, the browse button and textbox are both disabled...any idea why? Oct 9, 2016 at 20:28
  • If there is no project loaded, the NDK option is disabled, thus making it impossible to assign Globaly for all new projects.
    – AaA
    Jul 11, 2017 at 8:49
3

File > Project Structure > SDK Location Download the ndk and then sync the project hope it will solve the problem

3

now is deprecated. read documentation

add to build.gradle

android {
ndkVersion '21.0.6113669' //version
}
1

Execution failed for task ':app:stripDebugDebugSymbols'.

No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669

Open Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK -> SDK Tools -> Show Package Details -> Select "NDK" -> select missing package -> Apply https://github.com/facebook/react-native/issues/28404

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.