kevin4z
kevin4z

Reputation: 349

Android JNI ndk-build error: 'jni' has not been declared

I want to use dynamic registration in native method, so I need set JNI_onLoad function. I just write a function to get sum of two numbers. But, it can't build correctly. How can I correct the error?

It seems can't find jni.h, but I already have #include<jni.h>

Upvotes: 0

Views: 1277

Answers (2)

Alex Cohn
Alex Cohn

Reputation: 57203

In Android NDK, <jni.h> does not define a jni namespace. Simply remove all jni::

#include <jni.h>
extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {

   JNIEnv env;
   vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
   jclass nativeClass = env->FindClass("com/test/NativeClass");

… and so on.

Upvotes: 2

Striker
Striker

Reputation: 505

Add header location to your android.mk

LOCAL_C_INCLUDES := "path to your header location"

Upvotes: 0

Related Questions