5

While trying to develop Hello World NDK program on Ubuntu with following parameters

  • sdk path is /home/gufran/ADT2/sdk
  • ndk path is /home/gufran/ADT2/android-ndk-r10e

I have successfully generated com_appxperts_firstndkapp_MainActivity.h and also MyJNI.c. Now I would like generate the .so files with command

home/gufran/ADT2/android-ndk-r10e/ndk-build.cmd

but its giving error

bash: home/gufran/ADT2/ndk/ndk-build.cmd: No such file or directory

Also tried

ndk-build.cmd

still error

ndk-build.cmd: command not found

Please note the NDK path is already set as

gufran@gufranKhurshid:~$ export NDK_HOME=home/gufran/ADT2/android-ndk-r10e
jww
  • 97,681
  • 90
  • 411
  • 885
Gufran Khurshid
  • 888
  • 2
  • 9
  • 28

2 Answers2

2

ndk-build.cmd command not found...

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. For Ubuntu, I believe you use .profile. Tools like ndk-build and keytool are on path:

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

# 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"

Finally, run ndk-build, not ndk-build.cmd. I believe ndk-build.cmd is for Windows.

jww
  • 97,681
  • 90
  • 411
  • 885
  • `ndk-build.cmd` is indeed for Windows. On Linux and Mac OS X, it's `ndk-build` that should be executed instead. – ph0b Jun 29 '15 at 12:40
1

First of all, locate your jni directory of your project in command-prompt if your .c files are available in it.Then just type command :

export NDK=enter your ndk path here  
export PATH=$NDK:$PATH 

then, run command ndk-build. it will generate your *.so files in libs folder

AT82
  • 71,416
  • 24
  • 140
  • 167
  • I got this error line 2: dirname: command not found line 3: /Users/mdmaidul.islam/Documents/RD/NaussSample/build/ndk-build: No such file or directory. Please help me – Md Maidul Islam Aug 22 '17 at 09:05