6

XA5104: Could not locate the Android NDK. Please make sure the Android NDK is installed in the Android SDK Manager, or if using a custom NDK path, please ensure the $(AndroidNdkDirectory) MSBuild property is set to the custom path.

The NDK location is set to the ndk within the android sdk but still this shows up

Nada
  • 69
  • 1
  • 3

8 Answers8

10

All the answers above are valid.

But in case you can't change the default location of the Android NDK through the settings (it was my case, I think it's a Windows 11 problem as surprising as it may sound):

  • Make sure you installed NDK, if not: Tools > Android > Android SDK manager > Tools > select NDK > Apply Changes

  • Create a folder named "AndroidNDK64" in C:\ProgramData\Microsoft

  • Move the C:\Microsoft\AndroidNDK\android-ndk-... folder to the folder you just created

It worked for me and I hope it works for you too

Bryce Friha
  • 186
  • 2
  • 11
  • 5
    Your answer worked for me. Maybe you got a -1 because the last step : "Move the C:\Microsoft\AndroidNDK\android-ndk-..." is the wrong path. It should be "...C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-...". The only difference from your instructions and what I did was I downloaded the NDK directly from https://developer.android.com/ndk/downloads. – Bkins Jan 11 '22 at 07:25
  • Thanks! however the path is the right one as far as I'm concerned, at least – Bryce Friha Jan 22 '22 at 18:23
  • 1
    This worked for me getting a xamarin forms android project running in VS2022 17.05. The folder that worked for me was ```C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r21e``` – Adam Diament Jan 27 '22 at 11:23
  • 1
    Thanks @AdamDiament, I think I'll edit my answer as most people have a different folder. Which version of VisualStudio do you run? – Bryce Friha Feb 03 '22 at 11:17
  • 1
    VS 2022 community edition for windows, v 17.0.5 – Adam Diament Feb 06 '22 at 15:24
  • Incidentally, compilation on xamarin android in vs 2022 is unusably slow. If anyone reading this thread has any leads, pls hit me up! – Adam Diament Feb 06 '22 at 15:25
6

I came across this issue and it turned out to have nothing to do with the Android NDK. I was trying to deploy a debug version of my app on top of a release build, changing back to debug or uninstalling my app solved the problem.

Muhammad Khan
  • 991
  • 1
  • 12
  • 26
5

happens to me after updating VS 2019 to Version 16.11.5 two days ago, it happens before AND after I install ndk from Android SDK Manager, and Android NDK Location setting is NOT in VS Options->Xamarin->Android Setting, check this FAQ https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/android-sdk-location?tabs=windows

Leowan
  • 61
  • 6
3

I had same issue just reverted to version 21.4.702 and everyting started to work

valentasm
  • 2,137
  • 23
  • 24
1

Had the same issue on Visual Studio for Mac. Downgrading to 21.4.7075529 allowed the Android project to build and deploy.

1

I was getting this error after changing to a Release build and trying to deploy. I tried the other answers and made sure the app was not present on the device. Nothing worked.

What did work, was opening the Android SDK manager and uninstalling the NDK and then re-installing.

After that, I was able to deploy the Release config of the app with no problem.

This was VS2019 for Windows 10.

henda79
  • 465
  • 3
  • 13
0

I had the same issue and fixed it by adding the NDK manually. Please follow the steps down below.

  1. Make sure that you have already installed NDK from Visual Studio's Android SDK Manager window.
  2. Copy "ndk-bundle" folder from "C:\Program Files (x86)\Android\android-sdk"
  3. Paste it under the "C:\ProgramData\Microsoft\AndroidNDK64" path.
  4. Rename the pasted "ndk-bundle" folder to "android-ndk-r21"

Finally, run the project and enjoy.

0

just toasted this problem and suggestions here either outdated or makes less sense. You dont need to separately install NDK, VS22 is deliviring it together with SDK installation. So there is a folder called NDKbundle under the SDK folder. Only problem here is that you need to make sure that you have the correct NDK. You cannot use latest version of NDK if you arent using everything up to date and if you comply with the NDK criterias. Here you can find the history

https://developer.android.com/ndk/downloads/revision_history

For example, if you are NDK23 you cannot use if you target APIs 16, 17, and 18 as it is stated in the release notes "Jelly Bean (APIs 16, 17, and 18) will not be supported in the next NDK release. ".

For me was the case, I had recently VS22 repair and somehow, SDK installed the latest version of NDK and i was getting this error. Once i downgraded back to NDK21 version, it worked like a charm.

Emil
  • 6,411
  • 7
  • 62
  • 112