Home » Android » android – Unresolved inclusion error while using NDK

android – Unresolved inclusion error while using NDK

Posted by: admin June 15, 2020 Leave a comment

Questions:

enter image description here
I am using Android NDK but the .c file in the JNI folder is showing the error of Unresolved inclusion as shown in the image: Kindly help me in solving this issue. I have tried almost everything I could find on internet but unable to solve it. For a C/C++ project I can use the build path\paths and symbols option to solve the inclusion but for an android project, this option is not available in project properties.

How to&Answers:

This is a bug in the ADT plugin (or rather, it sounds like an incompatibility with the newer version of CDT for Eclipse) on Windows documented here: http://code.google.com/p/android/issues/detail?id=33788

There’s a preview of a new version which fixes the problem described here: http://tools.android.com/download/adt-21-preview#TOC-Installation

Here’s what I needed to do to fix the problem:

  1. Enable Preview Tools in the Options of the SDK Manager, then install the preview version of the SDK tools.
  2. Install the preview version of ADT and NDK plugins in Eclipse using the link in the preview description linked above.
  3. Re-create my project so that I could re-do the “Add Native Support” step (apparently required for the fix to work).

It’s probably possible to accomplish #3 by editing appropriate project files rather than re-creating, but since I’m in early stages of development I didn’t experiment with that.

Answer:

Had the same issue, resolved it by fixing the path in project properties (C/C++ General / Paths and Symbols / Includes) from:

${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include

to:

${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include

Answer:

Android NDK Project -> New -> Folder -> Advanced -> Link to alternate location(Linked Folder)
Browser the path(for example):C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include. The path depends on the version of cygwin you use.

Answer:

In current Android NDK (Revision 10e) folder gnu-libstdc++/4.6 does not exists – you have to change Eclipse build include paths:

Project – Properties – C/C++ General – Paths and Symbols – Includes – GNU C, GNU C++

${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include

Change to:

${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include

Answer:

The only work around I’ve been able to find for this in my project is to disable the #include warnings in Eclipse Preferences -> General -> Editors -> Text Editors -> Annotations -> C/C++ Indexer Markers.

Since the C/C++ project preferences don’t show up in Android projects, I haven’t been able to enter include directories for the NDK code.

Answer:

1 close project. open .project in another editor. delete the following:

......
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
......
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
......
<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>

2 delete .cproject

3 open project in eclipse, refresh. Right click, properties->Android Tools -> Add Native Support. Solved, now we can ctrl + click to open link.

4 If methods and symbols still shows unresolved, you can try this: Go to the project’s Properties -> C/C++ General -> Code Analysis. Click the “Use project settings” radio button (or “Configure Workspace Settings…” button). Disable (uncheck) the “Method cannot be resolved” checkbox.