本文介绍了仅在eclipse中打开hello-jni.c文件时才在eclipse中编译Hello-Jni失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力为Android NDK构建示例HelloJni示例项目。



我如何设置环境: / p>

我按照开始在文档中的说明进行操作:android-ndk-r10d\docs\Getting_Started / html / index.html:


  1. 下载的Eclipse Luna

  2. 下载Android SDK

  3. 下载Android NDK: android-ndk-r10d

  4. 在首选项窗口 - > android - > NDK中设置日食中的NDK安装文件夹。 >
  5. 导入hellp-jni示例

  6. 右键单击HelloJni项目 - > Android工具 - >添加本机支持。


  7. 在我的设备上放置HelloJni库(不是测试)

应用程序正在运行,一切都在工作,我可以看到生成的.so文件每个架构的libs文件夹中的项目(对于每个架构,例如armebi,mips等)



这是一个打印屏幕,显示一切正常工作: / p>



现在这里是奇怪的部分...



问题:



如果我打开hello-jni.c文件在eclipse中进行编辑或查看,我突然看到编译错误,我无法构建,也无法再运行该项目...



这是一个打印屏幕,显示我打开文件后,我突然收到编译错误:





我已经尝试过了失败:


  1. 添加Android Native Nature,然后将其删除:
    删除.project文件
    buildCommand标签:org.eclipse.cdt.managedbuilde r.core.genmakebuilde,
    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和所有编译文件。
    然后添加Android Native Nature。

根据这个stackoverflow链接:



这是一个打印屏幕:



失败


  1. 从项目为他工作的朋友复制eclipse Luna安装。

失败



我已经花了几个小时,我找不到任何解决这个问题的解决方案。



请帮助

解决方案

FWIW,Eclipse似乎有与 r10d 版本的问题的Android NDK。请参阅。我建议您尝试 r10c 而不是#worksforme:)


I have been trying endlessly to build the sample HelloJni sample project for the Android NDK.

How I set up the environment:

I followed the instructions of the getting started in the docs: android-ndk-r10d\docs\Getting_Started/html/index.html:

  1. Downloaded Eclipse Luna
  2. Downloaded the Android SDK
  3. Downloaded the Android NDK: android-ndk-r10d
  4. Set the NDK installation folder in eclipse in preferences window -> android -> NDK.
  5. Imported the hellp-jni sample.
  6. Right click on the HelloJni Project -> Android tools -> Add native support.
  7. Cleaned and Built the project.
  8. Ran on my device the HelloJni library (not the tests)

And the app is running and everything is WORKING and I can see the generated .so file per architecture in the libs folder of the project (for every architecture, for example armebi, mips, etc...)

Here is a Print Screen showing everything is working:

Now here comes the strange part...

The Problem:

If I open the hello-jni.c file for editing or viewing in eclipse, I suddenly see compilation errors and I can't build and can't run the project anymore...

Here is a Print Screen showing that after i open the file, I suddenly get compilation errors:

What I have already tried but failed:

  1. Adding the Android Native Nature, then removing it by:Deleting the .project file,the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.genmakebuilde,the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderand removing 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]removing the .cproject and all compiled files.Then adding back the Android Native Nature.

According to this stackoverflow link:Eclipse ADT - Unresolved inclusion jni.h

Failed

  1. Once I got the error of (I am not getting it anymore): Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath". So I Googled and I changed the build settings to give the absolute path of my NDK installation folder:

According to this stackoverflow link:Unable to launch cygpath in android

Here is a Print Screen:

Failed

  1. Changing the Used tools from Android GCC Compiler to GCC C Compiler

according to this stackoverflow link:Android NDK build, Method could not be resolved

Here is a Print Screen:

Failed

  1. Copying an eclipse Luna installation from a friend that has the project working for him.

Failed

I have been spending hours on this and I couldn't find any solution to why this is happening.

PLEASE HELP

解决方案

FWIW, Eclipse seems to have issues with the r10d version of Android NDK. See https://code.google.com/p/android/issues/detail?id=97023. I suggest you try r10c instead #worksforme :)

这篇关于仅在eclipse中打开hello-jni.c文件时才在eclipse中编译Hello-Jni失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:12