I am doing Java Native Development for android. And I use Android NDK and eclipse as IDE. Very frequently I write a C/C++ code in jni and eclipse shows errors such as:
Could not be resolved:
- JNIEXPORT
- JNICALL
- JNIEnv
- jobject
- jint
But on the other hand ndk-build
builds the .so file sucessfully without any error or even warnings. How to fix this in eclipse?
If you need here is the code I compile:
#include <jni.h>
#include <unistd.h>
int multiply(int i, int j) {
int x = i * j;
return x;
}
extern "C" {
JNIEXPORT jint JNICALL Java_cookbook_chapter3_HelloNDKGDBActivity_multiply(JNIEnv* env, jobject o, jint pi, jint pj){
int i = 1, j = 0;
while (i) {
j=(++j)/100;
}
return multiply(pi, pj);
}
}