Question

I'm trying to compile the Android ndk example android-ndk-r6b/samples/hello-jni and i'm not having luck.

The compilation error i'm getting is:

 $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ ndk-build
    Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
    Gdbsetup       : libs/armeabi/gdb.setup
    Compile thumb  : hello-jni &lt= hello-jni.c
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:17:20: error: string.h: No such file or directory
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:18:17: error: jni.h: No such file or directory
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Java_com_example_hellojni_HelloJni_stringFromJNI'
    make: *** [/media/rober/android/android-ndk-r6b/samples/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1


The environment:


     Ubuntu
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ lsb_release -a
        No LSB modules are available.
        Distributor ID: Ubuntu
        Description:    Ubuntu 11.10
        Release:    11.10
        Codename:   oneiric

        Java
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ java -version
        java version "1.6.0_22"
        Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
        Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)

        Make
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ make -v
        GNU Make 3.81
        Copyright (C) 2006  Free Software Foundation, Inc.
        This is free software; see the source for copying conditions.
        There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
        PARTICULAR PURPOSE.
        This program built for i686-pc-linux-gnu

        AWK
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ awk -W version
        mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
        compiled limits:
        max NF             32767
        sprintf buffer      1020

        Android
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ export | grep ANDROID
        declare -x ANDROID_HOME="/media/rober/android/android-sdk-linux_86"
        declare -x ANDROID_NDK="/media/rober/android/android-ndk-r6b/"
        declare -x ANDROID_NDK_ROOT="/media/rober/android/android-ndk-r6b/"
        declare -x ANDROID_SDK_HOME="/media/rober/android/android-sdk-linux_86"

        PATH ( splitted by "\n" for easy reading )
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ export | grep PATH | grep bin
        declare -x PATH="
        /media/rober/dev/apache-ant-1.7.1/bin:
        /media/rober/dev/apache-maven-3.0.3/bin:
        /media/rober/android/android-sdk-linux_86/platform-tools:
        /media/rober/android/android-sdk-linux_86/tools:
        /media/rober/android/android-ndk-r6b/:
        /usr/lib/lightdm/lightdm:
        /usr/local/sbin:
        /usr/local/bin:
        /usr/sbin:
        /usr/bin:
        /sbin:
        /bin:
        /usr/games:
        /media/rober/dev/jdk1.6.0_22/bin:
        /media/rober/dev/apache-ant-1.7.1/bin:
        /media/rober/dev/apache-maven-3.0.3/bin:
        /media/rober/android/android-sdk-linux_86/platform-tools:
        /media/rober/android/android-sdk-linux_86/tools:
        /media/rober/android/android-ndk-r6b/

I have the feeling that i'm missing an environment variable or some sort of configuration that tells the ndk where to look up for the string.h and jni.h files, even when they are inside the same ndk directory structure, but i'm not really sure what's going.

All sort of tips are very welcome :)

Was it helpful?

Solution

EDIT: i updated to r7 and everything works just fine, weird.

OTHER TIPS

Try

find /media/rober/android/ -name string.h

or

sudo find / -name string.h

if first won't work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top