22

The Android NDK can now be installed directly from the SDK manager instead of only as a separate download. How can I install the NDK package from the command line?

I've tried:

android sdk update -u -n -a

but no NDK package appears to be visible in the listing. It only shows up in the UI.

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225

2 Answers2

34

In Android Studio 2.3 is sdkmanager tool

It is located in the sdk directory (i.e. ~/Android/Sdk/tools/bin)

to get a list of installed and available packages goto the directory where the sdkmanager binary is located and type ./sdkmanager --list

to install NDK directly use ./sdkmanager "ndk-bundle"

(./sdkmanager "lldb;2.3", ./sdkmanager "cmake;3.6.3155560")

https://developer.android.com/studio/command-line/sdkmanager.html

ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema is throwing, do you know why? – Crono Aug 21 '18 at 21:57
  • seems to be common since 2018 don't know why https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a/46405092 – ralf htp Aug 22 '18 at 07:54
  • JAXB was removed from the Java standards at the same time as the modules was introduced (it was moved into a module with Java9 but is entirely gone from Java11). – whizzter Nov 07 '18 at 21:38
  • This seems like the right idea, but it doesn't actually work. It does work if you don't specify a revision, but if you add a version (taken straight from the --list option), you'll get something like: "Warning: Failed to find package ndk-bundle;18.1.5063045" – James Moore Dec 07 '18 at 23:52
8
  1. Download zip file of required version of ndk from developer.android.com. E.g. for linux:

    wget https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip

  2. Extract zip to some folder, e.g. c:/android/android-ndk-r13b/

  3. Add/update the path to that folder in the local.properties file of your application.

    ndk.dir=c:\android\android-ndk-r13b

shtolik
  • 1,341
  • 22
  • 29
  • 2
    I specifically want to download it as an SDK component. – Jake Petroules Feb 22 '17 at 07:11
  • Sorry to inform, but it's not served by android.bat as sdk component as far as I see. Try to raise a suggestion to Google about it. And even the new sdkmanager.bat is not providing anything ndk related – shtolik Feb 22 '17 at 08:30
  • 1
    Updated url to download NDK: https://dl.google.com/android/repository/android-ndk-r14b-darwin-x86_64.zip – ultraon May 10 '17 at 10:59