35

I have downloaded android NDK from here: http://developer.android.com/tools/sdk/ndk/index.html
for Linux 64-bit (x86) android-ndk-r10c-linux-x86_64.bin. How I do install it? The instructions don't work. My OS is

57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
Vardan95
  • 602
  • 1
  • 7
  • 15

10 Answers10

36

The Standard Way

Android's NDK now ships as an self extracting executable. You likely need to set the executable bit:

$ chmod +x android-ndk-r10c-linux-x86_64.bin
$ ./android-ndk-r10c-linux-x86_64.bin

The above will cause the NDK to extract into the current working directory.

Manual Extraction

Since the .bin file is really just a 7-Zip self extracting archive, you can manually extract the contents if needed:

$ 7za x -o/path/to/extract/to/ android-ndk-r10c-linux-x86_64.bin


7-Zip is available in Ubuntu for example via apt-get:

$ sudo apt-get install p7zip-full

Update
As of at least r14b on the NDK download page, we're back to standard ZIP archives.

NuSkooler
  • 5,391
  • 1
  • 34
  • 58
  • 1
    You may want to post some more information other than "It doesn't work". See http://stackoverflow.com/help/how-to-ask – NuSkooler Nov 18 '14 at 20:38
  • ./android-ndk-r10c-linux-x86_64.bin: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory – Vardan95 Nov 20 '14 at 18:33
  • @Vardan95: That is answered here: http://stackoverflow.com/questions/11471722/libstdc-so-6-cannot-open-shared-object-file-no-such-file-or-directory Alternatively, you can use the manual instructions I added. – NuSkooler Nov 20 '14 at 21:15
  • and where can this .bin file be found? All I see are .zip files, (and no README to be seen anywhere, shame on you Google) – axd Apr 16 '17 at 16:48
9

If you already have AndroidStudio installed:

You can install NDK using the SDK Manager from within Android Studio

From an open project, select Tools > Android > SDK Manager from the menu bar. Click the SDK Tools tab. Check the boxes next to LLDB, CMake, and NDK. Apply

enter image description here:

Maksim Turaev
  • 4,115
  • 1
  • 29
  • 42
  • 1
    This does not get the right Android NDK version needed for the Unity project I am working on. – CrandellWS Feb 01 '17 at 14:28
  • 2
    ubuntu does not install by default Android Studio and nowhere in the question is mentioned that it is installed. So the answer is incorrect unless: **First install Android Studio** is provided before "_install NDK using the SDK Manager from within Android Studio_" – ilias iliadis Jan 09 '19 at 22:44
8

Another way to download and install (unpack) it (size of zip is ~820MB, unzipped is ~2.9G):

wget https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip
unzip android-ndk-r20-linux-x86_64.zip
0x8BADF00D
  • 7,138
  • 2
  • 41
  • 34
3

Go to the directory where you downloaded it. Then execute:

chmod +x android-ndk-r10c-linux-x86_64.bin
./android-ndk-r10c-linux-x86_64.bin

It should unpack right there. The toolchain will be in android-ndk-r10c-linux-x86_64/toolchains. The root folder might have a slightly different name.

Stuart Axon
  • 1,844
  • 1
  • 26
  • 44
jan
  • 336
  • 1
  • 4
  • 2
    Unfortunately this is not correct, because `android-ndk-r10c-linux-x86_64.bin` is an ELF executable, not a shell script. – vitaut Feb 05 '15 at 14:01
1

I have done like below

Install 7-Zip via apt-get like this

$ sudo apt-get install p7zip-full

go to folder where your ndk bin is and then execute the command

$ 7z x *bin
N J
  • 27,217
  • 13
  • 76
  • 96
1

I have androidBBQ which is archlinux based, installed using vmware. But I guess my instructions should be the same for any linux distribution. I used AndroidStudio's built-in SDK manager, to try installing NDK. Download failed because there was no space in /tmp. Turns out that most Linux distros have ramdisk baesd tmpfs (temporary file system in RAM which is mounted at /tmp) and there is no separate partition which could be extended. /tmp is mounted usually by using 50% of available RAM.

Install NDK using Android Studio's built-in SDK manager ->not so convenient
a) Extend /tmp
I edited my fstab as root, using this command :

sudo nano /etc/fstab  

I appended this line to my fstab

none /tmp tmpfs size=8G 0 0  

Note: If no such line exists, add above line at end of fstab. If any such line exists, it means you had already extended your /tmp and it was still insufficient. So, only change the "size" value, by raising it by a few GBs.
Then I rebooted. Once I did, my /tmp was extended to 8GB size. For development purposes, I guess we should readily extend our /tmp because we will have to do it anyway some time later. Size of /tmp is not dependent on free space in our hard disk (whether virtual or physical).

b) run NDK install again
I ran the NDK install from within AndroidStudio again. It had to download the NDK zip afresh. Unfrotunate that there is no resume/recheck function to resurrect broken installs. My download speed was slow, so I minimized the virtual linux's window and continued to read news. Later, I guess memory/page swapping occurred. The download failed. I restarted Linux and restarted NDK install the same way. This time, I let the virtual Linux machine stay on foreground. NDK installed fine with this log :

Installing NDK
Downloading https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
Installing NDK in /opt/android-sdk/ndk-bundle


Manual NDK install in Linux (preferable) I am amazed that official Android dev section did not bother indicating exact install location of Android NDK. Android Studio looks for NDK at:

/opt/android-sdk/ndk-bundle  

So, do this:
1. Download NDK zip from https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
2. Open the zip, and open the android-ndk-r12b-linux-x86_64 (or similar) folder present inside.
3. Now extract all these files and folders to /opt/android-sdk/ndk-bundle.
4. Launch Android Studio, and it should detect presence of NDK.

n00by
  • 21
  • 2
1
  1. Download android ndk for linux x86_64 version using wget wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
  2. Change the permissions chmod 755 android-ndk-r25b-linux.zip
  3. Unzip to destimation path, for ex. /root/Library/Android/sdk/ndk.. etc. This will install at /root/Library/Android/sdk/ndk/android-ndk-r25b unzip android-ndk-r25b-linux.zip -d /root/Library/Android/sdk/ndk
appapurapu
  • 602
  • 7
  • 6
0

Ubuntu will error:bash: ./android-ndk-r10c-linux-x86_64.bin: No such file or directory

slove: apt-get install p7zip-full

7z x *bin

hnrayer
  • 61
  • 3
0

you can use sdkmanager, below is the detail code;

wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O android-sdk.zip
unzip android-sdk.zip -d .
rm -f android-sdk.zip
mkdir -p /opt/android-sdk/ # you can choose the folder to install all the android sdk\ndk\build-tools ...
mv ./tools/ /opt/android-sdk/
export ANDROID_HOME="/opt/android-sdk"
export PATH="${ANDROID_HOME}/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:${PATH}"
yes | sdkmanager --licenses
sdkmanager "platforms;android-27" 
... 
0

Use android cli tool sdkmanager. It's recommend to install the NDK side-by-side to your SDK, that means you should install the NDK under$ANDROID_SDK_ROOT/ndk. If you use a build tool like Gradle you can specify your version via build.gradle and it will download/install if the NDK is missing into Android SDK direktory during build process. If you want to install NDK manually you can run (replace version no with the version of your choice):

sudo env "PATH=$PATH" sdkmanager --install "ndk;25.1.8937393" --sdk_root=$ANDROID_SDK_ROOT --verbose
Hölderlin
  • 424
  • 1
  • 3
  • 16
  • the echo commands seem to give the wrong result, the first one has an extra quote before the path so it isn't quoted properly, the second one for me was replaced with the actual values (the whole $PATH and the android was still empty) – XIU Mar 13 '23 at 20:31