Android NDK构建,方法无法解决 [英] Android NDK build, Method could not be resolved

查看:153
本文介绍了Android NDK构建,方法无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用本机代码的Android项目。通过调用 ndk-build 命令,无需任何错误或警告就可以从命令行构建本机代码。但是当我在ADT中打开它时会显示以下错误。





错误消息:方法CallStaticIntMethod无法解析。有很多文件在项目中有类似的错误。



我重新检查配置,这里是我所拥有的。 Android构建,工具链和包含正确配置(见下图)









所需的包含项目资源管理器中也可见,它们是有效的(不为空,指向正确的头文件)。





但是当我清除项目和 Build 它,错误仍然存​​在。任何有关如何解决这个问题的想法?



配置:ADT 22.6.2,NDK r9d(64位),OSX 10.9.2

解决方案

经过一些与偏好的斗争,我终于找到了一个解决方案。这是NDOS插件中的错误,这是向AOSP报告的但尚未修复。答案的过去在评论#50中描述。这是为我工作的顺序。


  1. 打开项目属性 - > C / C ++ - > 工具陈编辑器

  2. 二手工具部分替换 Android GCC编译器 GCC C编译器。如果section为空,那么只需在其中添加 GCC C Compiler 条目。

  3. 打开项目属性 - > C / C ++常规 - > 路径和符号,并添加要包括的h文件所在的目录。首先使用上移按钮添加包含本地包含( / AudioPlayer / jni )的文件夹。然后添加平台和工具链包括。内置的包括应该保持在底部。

    在我的情况下,工具链的完整路径包括下面。这些是原始 Android GCC编译器工具链的内置路径,我们已在步骤2中替换。

     $ $ $ $ $ / pre> 

  4. 确定按钮,清洁重新构建项目。所有错误都必须消失。如果他们留下来,尝试从问题中删除它们,再次重新构建项目。


更新:我找到了另一个地方,您可以在其中添加包含文件的路径。但是它似乎依赖于Eclipse版本。 项目设置 - > C / C ++常规 - >处理器包括路径,宏等 - > CDT用户设置条目 - >添加。在添加上面列出的路径之后,再也没有编译问题。发展很有趣。


I have an Android project with native code. I'm able to build native code from command line by calling ndk-build command with no errors or warnings. But when I open it in ADT it shows the following error.

Error message: Method CallStaticIntMethod could not be resolved. There are many files with similar errors in the project.

I double checked configuration and here is what I have. Android build, tool chain and includes are properly configured (see pictures below)

Required includes are also visible in the Project Explorer and they are valid (not empty and point to correct header files).

But when I Clean the project and Build it, the errors are still there. Any ideas on how to solve this?

Configuration: ADT 22.6.2, NDK r9d (64-bit), OSX 10.9.2

解决方案

After some struggling with preferences, I finally found a solution. This is a bug in NDK plugin which was reported to AOSP but not yet fixed. A past of the answer is described in comment #50. Here is the sequence which worked our for me.

  1. Open Project Properties -> C/C++ Build -> Tool Chan Editor
  2. In the section Used Tools replace Android GCC Compiler with GCC C Compiler. If section is empty, just add GCC C Compiler entry in there.
  3. Open Project Properties -> C/C++ General -> Paths and Symbols and add directories, where your h-files to be included are located. Use Move up button to add a folder with your local includes (/AudioPlayer/jni in my case) to the first place. Then add platform and toolchains includes. Built-in includes should stay at the very bottom. In my case the full paths to the toolchain includes were like below. These are built-in paths of original Android GCC Compiler toolchain, which we have replaced at step 2.

    /Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include
    /Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include-fixed
    

  4. Press OK button, clean and re-build the project. All errors must go away. If they stay, try to remove them from Problems view and re-build project once again.

Update: I have found another place, where you can add paths to include files. However it appears to be Eclipse version dependent. Project Settings -> C/C++ General -> Processor Include Paths, Macros etc. -> CDT User Settings Entries -> Add. After I added the paths listed above, there is no compilation issues anymore. Development is fun again.

这篇关于Android NDK构建,方法无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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