How to install Android NDK on Ubuntu 16.04 / 18.04

The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.

To install and configure the NDK, follow these steps:Download android ndk suitable for your platform from http://developer.android.com/ndk/downloads/index.html

 $ mkdir ~/android_ndk 
 $ cd ~/android_ndk 
$ wget -c https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip 

Now extract the zip as,

 $ unzip android-ndk-r20-linux-x86_64.zip 

This will extract as “Extracting¬† android-ndk-r20” into folder “android-ndk-r20” in ~/android_ndk directory. When uncompressed, the NDK files are contained in a directory called android-ndk-<version>. You can rename the NDK directory if necessary and you can move it to any location on your computer.

Export the NDK path into environment variables,

 $ export PATH=$PATH:~/android_ndk/android-ndk-r20 

OR You can also edit your ~/.bashrc file and append above line to add NDK permanently to your path to avoid typing above command always.

Now, you can confirm that ndk-build is added into environment as,

$ which ndk-build 
/home/myuser/android_ndk/android-ndk-r20/ndk-build 
Follow Lynxbee

Leave a Reply / Ask Question