10

I am stuck with this following problem on Mac OS X(10.8.4) and eclipse JUNO since 10 days and I haven't found anything working on web.

I have downloaded and unzipped the android NDK. After that, I have set the NDK location in 'Android' option in preferences menu. I want to run a sample opencv code(https://www.dropbox.com/s/6s3qwkon9v67u5z/tutorial-3-native.rar) on the android ADT.

While building, it gives the following console output

**** Build of configuration Default for project OpenCV Sample - native-activity ****

"/ndk-build" 

Cannot run program ""/ndk-build"": Unknown reason
Error: Program ""/ndk-build"" is not found in PATH

PATH=[/usr/bin:/bin:/usr/sbin:/sbin]

**** Build Finished ****

I don't know anything about PATH variables/Environment Variables. Please provide step by step procedure to rectify the above error.

mohit
  • 413
  • 2
  • 7
  • 19
  • search "how to add a folder to PATH Mac OS" on Google – VinceFR Jul 16 '13 at 07:57
  • @VinceFR I added this address to PATH /Users/mohitagrawal/Downloads/android-ndk-r8e , still the error remains same. I tried the same by adding adding path "/Users/mohitagrawal/Downloads/android-ndk-r8e/" , yet the error is same. – mohit Jul 16 '13 at 17:27
  • http://stackoverflow.com/questions/11825534/set-build-path-in-eclipse-for-ndk-program Look at the second answer – 1087427 Aug 13 '13 at 23:18

3 Answers3

12

In Eclipse, highlight your Project, then from the Eclipse menubar at the top, select 'Project->Properties'.

In the list on the left, click on the arrow next to the item 'C/C++ Build' and highlight the item 'Environment'.

In the box that reads 'Environment variables to set' you will have 2 items, CWD and PWD. Click the button that read 'Add...'

In the box that appears, select the Name field and type in NDKROOT.

In the field that reads Value type in the path to where you unzipped the Android NDK.

Click on 'Apply". Boom, done. Do this to any other projects that rely on the NDK.

DasBoos
  • 313
  • 1
  • 3
  • 8
5

ndk-build is in the root of the NDK folder.

If printenv PATH | grep ndk does not return a string, you cannot call it.

Append the following to $HOME/.bash_profile:

export NDK_ROOT="<whatever your NDK directory is>"
export PATH="$PATH:$NDK_ROOT"

Then, from the command prompt, type:

. ~/.bash_profile

Now you can run ndk-build from the command prompt.

Michael Labbé
  • 12,017
  • 4
  • 27
  • 36
  • I did as you mentioned and successfully edited the bash_profile but there is no change in error. I am building from eclipse. I am not sure how I can run ndk-build from the command prompt. – mohit Jul 16 '13 at 19:31
  • If you are building from Eclipse, the bash_profile change does nothing. Change your question to specify that you are building from Eclipse. – Michael Labbé Jul 16 '13 at 19:33
  • 1
    How to add NDK in windows? – praxmon Jan 16 '14 at 04:58
  • I believe its `ANDROID_NDK_ROOT`, and not `NDK_ROOT`. See David Turner's answer at [Recommended NDK Directory?](https://groups.google.com/forum/#!msg/android-ndk/qZjhOaynHXc/2ux2ZZdxy2MJ) – jww Jun 28 '15 at 22:41
0

Program “/ndk-build.cmd” is not found in PATH...

Put your tools on path. Also, you should export ANDROID_NDK_ROOT and ANDROID_SDK_ROOT. See David Turner's answer to Recommended NDK Directory? on the NDK mailing list for the reasons.

Here's what my .bash_profile looks like on OS X. Tools like ndk-build and keytool are on path:

$ cat ~/.bash_profile
export PS1="\h::\W$ "
...

# MacPorts Installer addition on 2012-07-19 at 20:21:05
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r10e
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx

export ANDROID_HOME=~/.android
export JAVA_HOME=`/usr/libexec/java_home`

export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"
jww
  • 97,681
  • 90
  • 411
  • 885