由于 eclipse 在 jni 中显示错误,如何从 eclipse 中的 Android 项目中删除本机支持?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11504258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove native support from an Android Project in eclipse because eclipse is showing errors in jni?
提问by Amit
I accidentally clicked on "Add Native Support" inside "Android Tools"... That messed up all the jni files of my project. How do I undo that ? How to remove Native support from my Android Project ?
我不小心点击了“Android 工具”中的“添加本机支持”……这搞砸了我项目的所有 jni 文件。我该如何撤消?如何从我的 Android 项目中删除本机支持?
回答by bleater
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.
我能找到的从项目中可靠地删除 C 特性的唯一方法是手动编辑项目的 Eclipse.project
文件。
Close the Eclipse project (e.g. by quitting Eclipse).
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 nameorg.eclipse.cdt.managedbuilder.core.genmakebuilder
and all its children, and the<buildCommand>
node with nameorg.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>
Completely remove the
.cproject
file.
关闭 Eclipse 项目(例如通过退出 Eclipse)。
.project
在文本或 xml 编辑器中打开文件。至少有 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>
彻底删除
.cproject
文件。
回答by Tancho
With the new ADT 20, if the project has a jni folder or/and an Android.mk file the c++ nature is added by the plugin by default,
使用新的 ADT 20,如果项目有 jni 文件夹或/和 Android.mk 文件,则插件默认添加 c++ 性质,
In general to remove the C++ nature, you just need to delete the .cproject file in the project tree, remove and re-import project in the workspace and you're good to go (c++ project nature removed).
一般来说,要删除 C++ 特性,您只需要删除项目树中的 .cproject 文件,删除并重新导入工作区中的项目,就可以了(删除了 C++ 项目特性)。
But I think you should just add the macro definitions and build imports and eclipse will work just fine. If you go to
但我认为您应该只添加宏定义并构建导入,eclipse 就可以正常工作。如果你去
Project properties->C/C++ general->Paths and symbols
and there you add the path to the NDK includes for the corresponding platform (something like)
然后你为相应的平台添加 NDK 包含的路径(类似)
{NDK_PATH}/platforms/android-9/arch-arm/usr/include
and all your build script added imports as well as any build script declared macros eclipse will handle the jni stuff just fine.
并且您所有的构建脚本添加的导入以及任何构建脚本声明的宏 eclipse 都可以很好地处理 jni 的东西。
回答by WindRider
Open up your .project
file in a text editor and just delete the entries for CDT and C nature. They are easily distinguished from those of JDT. I have done this several times and it's nothing dangerous but make a backup copy for safety.
.project
在文本编辑器中打开您的文件,然后删除 CDT 和 C 性质的条目。它们很容易与 JDT 区分开来。我已经这样做了好几次,这没什么危险,但为了安全起见,请制作一个备份副本。
EDIT: It might be possible also with Project Properties -> Builders -> Remove CDT Builder but never tried it.
编辑:也可以使用 Project Properties -> Builders -> Remove CDT Builder 但从未尝试过。
回答by Son Nguyen Thanh
Do following steps, Hope it can help you.
按照以下步骤操作,希望能帮到你。
After Android tools ->Add native support. It will gen cpp file on jni folder. And eclipse can not resolved it. This is a fixing way.
在 Android 工具 -> 添加原生支持之后。它将在 jni 文件夹中生成 cpp 文件。而eclipse无法解决它。这是一种固定方式。
Step 1
Right Click PJ -> add New Folder -> In dialog add new folder, click Advanced>> check Linked Folder -> Borrow to [{NDK_PATH}/platforms/android-21/arch-arm/usr/include ] ( i used android -21, you can change it) (1)--> OK
Step 2
Right click PJ -> Properties -> C/CC general ->Paths and Symbols ->Include tab -> Add ->Work Space -> select include folder (1) in your project -> OK . Refresh and rebuild.
第1步
右键单击 PJ -> 添加新文件夹 -> 在对话框中添加新文件夹,单击高级>> 检查链接文件夹 -> 借用 [{NDK_PATH}/platforms/android-21/arch-arm/usr/include] (我使用 android -21,你可以改)(1)--> OK
第2步
右键单击 PJ -> 属性 -> C/CC 常规 -> 路径和符号 -> 包含选项卡 -> 添加 -> 工作空间 -> 在您的项目中选择包含文件夹 (1) -> 确定。刷新和重建。
回答by Varun Chaudhary
just remove the jni folder and clear project in c/c++ interface
只需删除 jni 文件夹并清除 c/c++ 界面中的项目