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.

Vinayak Garg
  • 6,518
  • 10
  • 53
  • 80
  • set sdk and ndk path in local.properties file – Sabish.M Aug 26 '16 at 06: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. – Vinayak Garg Aug 26 '16 at 06: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](http://stackoverflow.com/a/30138016/608639) and setting `ANDROID_NDK_ROOT`. – jww Aug 26 '16 at 06: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. – Vinayak Garg Aug 26 '16 at 06: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 '16 at 06:51
  • In the `local.properties` of your project add the property as `ndk.dir=D:\NDKAndroid\` – Madhukar Hebbar Aug 26 '16 at 06:54
  • Note: As of SDK 30, setting ndk.dir in local.properties has been deprecated. – Android Dev Sep 23 '21 at 17:05

7 Answers7

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.

AaA
  • 3,600
  • 8
  • 61
  • 86
Arpit Garg
  • 8,476
  • 6
  • 34
  • 59
  • @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 '16 at 07: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 '17 at 07: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 '17 at 08: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 '19 at 12:28
  • yes changing path to default ndk in android sdk package accepted thanks for the answer – Sunil Chaudhary Feb 10 '20 at 09:58
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.

suther
  • 12,600
  • 4
  • 62
  • 99
5

Set ndk folder location in local.properties file

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

Happy Fluttering ....

Koushik Deb
  • 320
  • 3
  • 10
3

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

Sabish.M
  • 2,022
  • 16
  • 34
  • 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 – Vinayak Garg Aug 26 '16 at 06:16
  • I am using Android Studio 2.1.3, and I have a different Project Structure screen. – Vinayak Garg Aug 26 '16 at 06:48
  • 3
    Using android studio 2.2, the browse button and textbox are both disabled...any idea why? – CuriousGeorge Oct 09 '16 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 '17 at 08:49
3

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

Ali Yar Khan
  • 1,231
  • 2
  • 11
  • 33
3

now is deprecated. read documentation

add to build.gradle

android {
ndkVersion '21.0.6113669' //version
}
dimvolk
  • 338
  • 3
  • 9
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

Amoo Faruk
  • 63
  • 5