Eclipse unable to resolve #include <jni.h>

9,600 views
Skip to first unread message

Tony Houghton

unread,
Jun 29, 2012, 11:38:02 AM6/29/12
to andro...@googlegroups.com
I'm trying to learn how to use the NDK by reading the book Android NDK
Beginner's Guide by Sylvain Ratabouil. I've set everything up according
to the book as best I can (it describes old versions of the tools in
some places and has some outright errors too) but I've got stuck at
editing and compiling C/C++ in Eclipse, because it complains about
"Unresolved inclusion: <jni.h>" in the header generated by javah.
ndk-build is fine with it though.

I would have expected Eclipse to set up the include paths for me, but it
doesn't seem to have done that and I don't know how to do it manually.
The book targets android-10 because that's the minimum version for some
feature it uses which hasn't been revealed so far, but the NDK only
provides jni.h for up to android-9. I changed the project's build target
to 8 (the SDK doesn't seem to support 9) but that didn't help.

I guess I need to add one of the paths from the NDK in Project
Properties > Paths and Symbols but I'm not sure about that. If your
project has a newer target than 9 are you supposed to just use the
include path for android-9 from NDK?

Aristarh Smertin

unread,
Jul 2, 2012, 4:16:34 PM7/2/12
to andro...@googlegroups.com
Yeah u right - include (both for C and C++) your TARGET sdk platform from Android NDK folder (platforms ->android-9-> arch-arm->usr-> include) hit Apply, when asking to rebuild hit yes, build your app, then you can remove just added paths - it all will be included properly with all standart.
Sometimes rebuilder forgets about it - Index-> Rebuild helps

пятница, 29 июня 2012 г., 19:38:02 UTC+4 пользователь realh написал:

Doug

unread,
Jul 5, 2012, 4:01:30 PM7/5/12
to andro...@googlegroups.com
It doesn't actually matter if Eclipse can find jni.h or other platform includes.  They will be found when you do ndk-build outside of Eclipse.  I have found that the latest ADT 20 suppresses those warnings now and has better ndk integration for your projects.

Doug

a1

unread,
Jul 6, 2012, 2:46:31 AM7/6/12
to andro...@googlegroups.com
I would have expected Eclipse to set up the include paths for me, but it
doesn't seem to have done that and I don't know how to do it manually.
 
It is easy (but tedious). Rightclick on project select Properties and under C/C++ Build select Paths and Symbols. In Includes tab you have to add all NDK includes directories:

platform includes:
NDK_ROOT/platforms/<api-level>/<arch>/usr/include (eg. NDK_ROOT/platforms/android-9/arch-arm/usr/include)

ARMEABI GCC specific libc includes:
NDK_ROOT/toolchains/<abi>/prebuilt/<os>/lib/gcc/<abi>/4.4.3/include (eg. NDK_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.4.3)

std includes (for c++ standard library) - this inclusion config is implementation specific (I use gcc std):
NDK_ROOT/sources/cxx-stl/include
NDK_ROOT/sources/cxx-stl/libs/<abi>/include (eg. NDK_ROOT/sources/cxx-stl/libs/armeabi/include)

When adding remember to check 'add to all languages' checkbox in add path dialog.

--
Bart

FedeX Tsapanas

unread,
Sep 2, 2014, 4:55:46 AM9/2/14
to andro...@googlegroups.com
You can do this by choosing Properties for the project

Properties -> C/C++ General -> Preprocessor Include..-> Entries -> Setting Entries -> CDT User Setting Entries

Add -> Include Directory -> File System Path, and enter the path of the includes like:
${NDK_ROOT}\platforms\android-5\arch-arm\usr\include

Also I found that this working for me only if I checked "Contains system headers" checkbox.
Reply all
Reply to author
Forward
0 new messages