Search code examples
androideclipseandroid-ndkadteclipse-cdt

Add C++ source files not located in "jni" directory to an eclipse android project


I have an android project with java and native code. Everything works fine, till today I just used eclipse to edit and build the java application, using ndk-build and ndk-gdb from command line, and managing/editing c++ sources outside of eclipse.

Now that I installed the adt ndk plugins, and that I can correctly build my native libs in eclipse, I am thinking about a way to add the c++ sources to the android project, so that I can browse them, perform searches and code completion in eclipse. I have A LOT of sources that are not in the jni directory of the android project, and I can't move them.

Then I saw in the project properties - under "C/C++ General -> Paths and Symbols" - an "Include" tab listing the include directories (I guess they are extracted from android.mk), and in the "Source Location Tab" I added a link to the "external" sources directory, naming it NativeSrc. I can indeed browse the sources in the project navigator, but when I open them they appear full of errors of the "Field XXX could not be resolved" kind.

I think there's something else I'm missing, maybe obvious but I can't see it. Or maybe my approach is totally wrong. Any suggestion?


Solution

  • Oh well, I got it. I had to right-click on the project in the navigator and select

    Index -> Rebuild
    

    in the context menu, then wait for a few time and, from the same menu, select

    Index -> Freshen All Files