drifter
drifter

Reputation: 683

error: jni.h: No such file or directory

I am getting error while trying to build android ndk project:

error: jni.h: No such file or directory

But: locate jni.h command show me:

locate jni.h
/usr/lib/jvm/java-6-openjdk-i386/include/jni.h

What is wrong in my actions?

EDIT:

If I hardcode it in the source code it work but I have a lot of files that are using this header. What I need to do that all my files can see /usr/lib/jvm/java-6-openjdk-i386/include/jni.h ?

Upvotes: 2

Views: 9666

Answers (1)

neevek
neevek

Reputation: 12128

Try setting the installation location of your NDK in PATH in your rc file, let's say ~/.bashrc:

NDK=/path/to/your/ndk/location    
export PATH=$PATH:$NDK

Source the rc file by running source ~/.bashrc.

Now when you run ndk-build, it will setup the whole build environment for you by running make command against a bunch of make files under $NDK/build/core, it will setup correct header file search path for your project depending on the android:targetSdkVersion setting in AndroidManifest.xml.

The jni.h needed by your NDK project is located under $NDK/platforms/android-14/arch-arm/usr/include.

Android NDK projects will not use any JNI header files under your JDK installation, files under /usr/lib/jvm/.... will never be touched.

Upvotes: 1

Related Questions