[转]解决更新Eclipse后,Android NDK开发找不到头文件的问题

进行Android NDK开发,最好用的还是Eclipse.新版本由于存在找不到头文件的问题,博主之前一直使用Eclipse Indigo. 使用下面的解决方法后,Juno,Kepler,Luna都正常了。

以下摘录自stackoverflow

原帖地址:http://stackoverflow.com/questions/23122934/eclipse-adt-unresolved-inclusion-jni-h

I ran into a similar problem with a working project with Android NDK-based code after updating to Eclipse Kepler. I observed similar things: the header files would correctly be listed under “includes” in the project, the actual build (via ndk-build) worked fine, but Eclipse’s editor couldn’t locate any headers in standard system directories (all headers with < > brackets).

I tried many different fixes, including switching toolsets, rebuilding indices etc. without success.

Finally, I removed the C nature entirely from the project, and added it back via the “Android Tools” menu in Eclipse.

Removing the C nature:

The only way I could find to reliably removed the C nature from the project was by hand editing Eclipse’s?.project?file for the project.

  1. Close the Eclipse project (e.g. by quitting Eclipse).
  2. Open the?.project?file in a text or xml editor. There will be at least 2?<buildCommand>?nodes that need to be removed. Remove the?<buildCommand>?node with name?org.eclipse.cdt.managedbuilder.core.genmakebuilder?and all its children, and the?<buildCommand>?node with name?org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder?and its children. Finally, remove the lines:
    <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>
  3. Completely remove the?.cproject?file.

Adding back the Android Native nature

Reopen the project in Eclipse. Then right-click on the project in the Project Explorer, and from the “Android Tools” contextual menu, choose “Add Native Support…”.

Android Tools -> Add Native Support...

Looking at the changes made in the .project and .cproject files before and after this change, it appears that it primarily gave new version numbers to the Android NDK tools. In any case, it solved the issue for me.

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: [转]解决更新Eclipse后,Android NDK开发找不到头文件的问题

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据