1

I am developing and android application in mac using Eclipse for android-ndk. I have already given NDK path in Eclipse. At the end when I am giving this command to build my application using android-ndk but getting the following errors:

command: ndk-build

ndk-build-bash: ndk-build: command not found

enter image description here

My Terminal Commands:

Muhammads-MacBook-Pro:~ UsmanKhan$ cd downloads
Muhammads-MacBook-Pro:downloads UsmanKhan$ cd 26thMarch2014
Muhammads-MacBook-Pro:26thMarch2014 UsmanKhan$ cd a2zLatest
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls
AndroidManifest.xml gen         proguard-project.txt
Thumbs.db       ic_launcher-web.png project.properties
assets          libs            res
bin         lint.xml        src
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/
com
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/com/testing/ndk
BuildConfig.class   R$dimen.class       R$string.class
FibLib.class        R$drawable.class    R$style.class
MainActivity.class  R$id.class      R.class
R$attr.class        R$layout.class
R$color.class       R$menu.class
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ mkdir jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin /classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
com_testing_ndk_FibLib.h
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ndk-build
-bash: ndk: command not found

At the end i am getting ndk-build error.

halfer
  • 19,824
  • 17
  • 99
  • 186
Usman Khan
  • 3,739
  • 6
  • 41
  • 89
  • 1
    could you provide some screenshots on how you defined the ndk path in eclipse? – Vincent De Smet May 09 '15 at 08:38
  • What are the values of `ANDROID_NDK_ROOT` and `ANDROID_SDK_ROOT`? Also see [Recommended NDK Directory?](https://groups.google.com/forum/#!msg/android-ndk/qZjhOaynHXc/2ux2ZZdxy2MJ) on the Android NDK mailing list. – jww May 09 '15 at 08:48
  • Possible duplicate of [ndk-build not found in Path](http://stackoverflow.com/questions/16312311/ndk-build-not-found-in-path) and [ndk-build not found as a command](http://stackoverflow.com/q/5847532/608639). – jww May 09 '15 at 08:50
  • @jww thanks for your reply. I didn't give any explicit values for ANDROID_NDK_ROOT and ANDROID_SDK_ROOT, i just give the location of my NDK in my eclipse preferences. Can you please guide me in this thing. – Usman Khan May 09 '15 at 08:54

2 Answers2

4

Instead of ndk-build command, simply type ~/Desktop/AndroidNDK/android-ndk-r10d/ndk-build in your terminal.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
0

I didn't give any explicit values for ANDROID_NDK_ROOT and ANDROID_SDK_ROOT, i just give the location of my NDK in my eclipse preferences. Can you please guide me in this thing

According to the Android folks on the Android NDK group (see Recommended NDK Directory?), uou should always provide values for ANDROID_NDK_ROOT, ANDROID_SDK_ROOT and ANDROID_SDK_HOME. Here is what they are used for:

  • ANDROID_NDK_ROOT → installation dirctory of NDK
  • ANDROID_SDK_ROOT → installation dirctory of SDK
  • ANDROID_SDK_HOME → location of SDK-related user files, defaults to ~/.android/ on Unix.

Put the tools on-path and export the env vars. Here's my .bash_profile for OS X.

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

# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r10d
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx
export ANDROID_SDK_HOME=~/.android

export JAVA_HOME=`/usr/libexec/java_home`

export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"

Then, source your profile changes (or log-off and then log-in).

Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
  • i am very new to MAC OSX, can you please give me little bit more example that how can i apply it on my terminal. I have seen the link but it didn't help me. I just closes my Terminal and opened it again. Please tell me where to put these command to make my path set for ndk. Thanks – Usman Khan May 09 '15 at 09:07
  • @UKhan - See [How to add a line to .bash_profile](http://superuser.com/q/678113/173513) on Super User. If it helps you, then you should upvote the question and answer. – jww May 09 '15 at 09:32