0

I am trying to learn android NDK and I am following the steps on http://developer.android.com/sdk/ndk/overview.html to build the hello-jni sample.

I have downloaded the Android NDK. But when I try to build or compile the code through terminal, it shows "command not found" error.

I am working on ubuntu. Can anybody please help me with the issue?

Akhila Nair
  • 291
  • 2
  • 6
  • 10
  • 2
    I guess you used `ndk-build`, which locates in $NDK_HOME. So you must add the NDK installation directory to `PATH`. You can add these 2 lines `NDK_HOME=/path/to/your/ndk_installation`, `export PATH=$NDK_HOME:$PATH` to `~/.bashrc`. After you finish the steps above, you need to source the `.bashrc` file, execute `source ~/.bashrc` in the terminal. And now you can use `ndk-build` from whichever directory in the terminal. – neevek May 23 '12 at 05:01
  • Add your steps one by one here.. It will be easy for us to identify the problem.. – Sandeep May 23 '12 at 12:40

1 Answers1

0

The steps for building hello-jni are:

Download Android NDK and unpack it in some directory (/opt for me):

Next, "cd /opt//samples/hello-jni" to the sample directory, and enter "/opt//ndk-build" to build the files and my output are as follows:

/opt/android-ndk/samples/hello-jni>/opt/android-ndk/ndk-build
[arm64-v8a] Gdbserver      : [aarch64-linux-android-4.9] libs/arm64-v8a/gdbserver
[arm64-v8a] Gdbsetup       : libs/arm64-v8a/gdb.setup
[x86_64] Gdbserver      : [x86_64-4.9] libs/x86_64/gdbserver
[x86_64] Gdbsetup       : libs/x86_64/gdb.setup
[mips64] Gdbserver      : [mips64el-linux-android-4.9] libs/mips64/gdbserver
[mips64] Gdbsetup       : libs/mips64/gdb.setup
[armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.8] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
[armeabi] Gdbserver      : [arm-linux-androideabi-4.8] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[x86] Gdbserver      : [x86-4.8] libs/x86/gdbserver
[x86] Gdbsetup       : libs/x86/gdb.setup
[mips] Gdbserver      : [mipsel-linux-android-4.8] libs/mips/gdbserver
[mips] Gdbsetup       : libs/mips/gdb.setup
[arm64-v8a] Compile        : hello-jni <= hello-jni.c
[arm64-v8a] SharedLibrary  : libhello-jni.so
[arm64-v8a] Install        : libhello-jni.so => libs/arm64-v8a/libhello-jni.so
[x86_64] Compile        : hello-jni <= hello-jni.c
[x86_64] SharedLibrary  : libhello-jni.so
[x86_64] Install        : libhello-jni.so => libs/x86_64/libhello-jni.so
[mips64] Compile        : hello-jni <= hello-jni.c
[mips64] SharedLibrary  : libhello-jni.so
[mips64] Install        : libhello-jni.so => libs/mips64/libhello-jni.so
[armeabi-v7a] Compile thumb  : hello-jni <= hello-jni.c
[armeabi-v7a] SharedLibrary  : libhello-jni.so
[armeabi-v7a] Install        : libhello-jni.so => libs/armeabi-v7a/libhello-jni.so
[armeabi] Compile thumb  : hello-jni <= hello-jni.c
[armeabi] SharedLibrary  : libhello-jni.so
[armeabi] Install        : libhello-jni.so => libs/armeabi/libhello-jni.so
[x86] Compile        : hello-jni <= hello-jni.c
[x86] SharedLibrary  : libhello-jni.so
[x86] Install        : libhello-jni.so => libs/x86/libhello-jni.so
[mips] Compile        : hello-jni <= hello-jni.c
[mips] SharedLibrary  : libhello-jni.so
[mips] Install        : libhello-jni.so => libs/mips/libhello-jni.so

Done. To build the output into apk files you will need to use Android SDK, see for eg:

Android NDK build with ANT script

Community
  • 1
  • 1
Peter Teoh
  • 6,337
  • 4
  • 42
  • 58