Trying to build a simple helloWorld android/java application with jni c code. I am using Eclipse Indigo on Windows 7. Installed ndk r8 in a non-space path, have the c library finally building fine with ndk-build.cmd. However, the header file generated by javah has unresolved errors,
It wasn't seeing the jni.h include yesterday but after a reboot this morning, that error has disappeared. I had an unresolved JNIEXPORT and JNICALL error as well, but #defining them seems to have solved that. Stuck on the last 3 above. Have searched google and Stack Overflow for answers but as soon as someone finds a solution they don't say what that solution was :(
I've checked the includes in java and c/c++ perspectives in project properties. It seems to be including jni.h directories that I want, I'm using the android-14 for arm platforms. The target is a 4.0.3 IceCream Sanwich (which confusingly is API 15?!). I was going to try and use an AVD for testing this. I've tried closing/reopening the project, deleting from Eclipse and reimporting, but none of that has worked.
Am I missing some includes? Which ones and where should I set them? Would really appreciate some help.
Right click project and go to properties properties.
Go to C/C++ General->Paths and Symbols.
In Includes->GNU C add the equivalent of this:
%ndkroot%\platforms\android-8\arch-arm\usr\include
You may want to point to other platform versions of the NDK, just change the android-8 part of the path.
Recently I've faced with the same problem. In my case the problem was that I converted my Eclipse project to C++ project, but I had used C type. So to solve this problem I simply deleted the line <nature>org.eclipse.cdt.core.ccnature</nature>
from .project
file from the project directory:
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
</natures>
Then restart your Eclipse. For more information you can read this.
Try to add a #undef __cplusplus
just before the #include
directives, like this:
#undef __cplusplus
#include <string.h>
#include <jni.h>
This will force Eclipse to consider the non-c++
definitions of the NDK objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With