Setting up Android NDK on Linux in Jenkins: A Guide

To install NDK using the Android SDK Manager, check the “Extras” section after opening the manager. Another option is to use the standalone SDK manager for Android, which is different from the one integrated into Android Studio. However, some users may not have the necessary tabs in their SDK Manager to complete the installation.

Question:

My Ubuntu system has Jenkins installed, and building was going smoothly until I began utilizing
android ndk
. I have downloaded the latest NDK and extracted it into the directory /opt/
android-sdk
-linux/ndk-bundle. Additionally, the file /etc/profile.d/android.sh contains relevant information.

export ANDROID_HOME="/opt/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
export ANDROID_NDK_HOME="/opt/android-sdk-linux/ndk-bundle"

However, I continue to encounter an error message stating “common:compileDebugNdk FAILED”.

The build encountered an exception and was unsuccessful.

  • The task ‘:common:compileDebugNdk’ failed to execute due to an error. To solve this issue, download the NDK from http://developer.android.com/tools/sdk/ndk/ and add ndk.dir=path/to/ndk in local.properties. If you are using Windows, ensure that you escape backslashes, for instance, use C:ndk instead of C:ndk.


Solution:

The entire instruction is to create a text file named

local.properties

and place it in the project directory on the Linux machine, containing only one line.

ndk.dir=/opt/android-sdk-linux/ndk-bundle

The file, which is automatically generated by
android studio
and typically found in

.gitignore

, fails to open in
Android Studio
when building your project with Jenkins.

Frequently Asked Questions