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.