Eclipse ADT - 未解决的包含jni.h [英] Eclipse ADT - Unresolved inclusion jni.h

查看:147
本文介绍了Eclipse ADT - 未解决的包含jni.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows平台上,我安装了最新版本的adt bundle(20140321)和ndk(r9d)。安装一样干净。环境变量NDK_ROOT,PATH等都被正确定义。



我正在处理的应用程序有一些C ++本机代码。该代码在Eclipse之外以及Eclipse中都可以正常工作。



然而,编辑器抱怨jni.h是一个未解决的问题。 >

项目 - >属性 - > C / C ++常规 - > PathsAndSymbols显示包含目录,其中一个目录是C:\adt\\\
dk\platforms\ Android的19\arch-arm\usr\include。我已经验证jni.h是否存在于此目录中。



我已经检查了该论坛上的所有其他消息,但找不到任何具体步骤。欣赏你的指导。问候。

解决方案

在更新到Eclipse Kepler之后,我遇到了一个与基于Android NDK代码的工作项目相似的问题。我观察到类似的东西:头文件将被正确地列在项目中的include下,实际构建(通过ndk-build)工作正常,但是Eclipse的编辑器无法在标准系统目录中找到任何标题(所有标题与< ;>括号)



我尝试了许多不同的修复,包括切换工具集,重建索引等,没有成功。



最后,我从项目中完全删除了C自然,并通过Eclipse中的Android Tools菜单将其添加回来。



删除C自然:



我可以找到可靠地从项目中删除C自然的唯一方法是手动编辑Eclipse的 .project 文件。


  1. 关闭Eclipse项目(例如退出Eclipse)。


  2. 在文本或xml编辑器中打开 .project 文件。至少需要2个< buildCommand> 节点。删除< buildCommand> 节点,名称为 org.eclipse.cdt.managedbuilder.core.genmakebuilder 及其所有子项,以及< buildCommand> 节点,名称为 org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 及其子。最后删除行:



    < 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. 完全删除 .cproject 文件。

    / li>

添加Android Native本机



在Eclipse中重新打开项目。然后右键单击项目资源管理器中的项目,然后从Android工具上下文菜单中选择添加本地支持...。





在此更改之前和之后的.project和.cproject文件中所做的更改,似乎主要为Android NDK工具提供了新的版本号。无论如何,它解决了我的问题。


On my Windows platform, I have the latest version of adt bundle (20140321) and ndk (r9d) installed. The installation is as clean as it gets. The environment variables NDK_ROOT, PATH, etc. are all defined properly.

The app I am working on has some C++ native code. The code builds fine both outside Eclipse as well as within Eclipse.

The problem, however, is that the editor complains that jni.h is an unresolved inclusion.

Project-->Properties-->C/C++ General-->PathsAndSymbols shows include directories and one of the directories is C:\adt\ndk\platforms\android-19\arch-arm\usr\include. I have verified that jni.h is present in this directory.

I have already checked all other messages on this forum but couldn't find any concrete steps. Appreciate your guidance. Regards.

解决方案

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...".

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 ADT - 未解决的包含jni.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆