我有一个带有本机代码的 Android 项目。我可以通过调用从命令行构建本机代码ndk-build
命令没有错误或警告。但是当我在ADT中打开它时,它显示以下错误。
错误信息:Method CallStaticIntMethod could not be resolved.
项目中有很多文件有类似的错误。
我仔细检查了配置,这就是我所拥有的。 Android 构建、工具链和包含内容均已正确配置(见下图)
所需的包含在项目资源管理器中也可见,并且它们是有效的(非空并指向正确的头文件)。
但当我Clean
该项目和Build
它,错误仍然存在。关于如何解决这个问题有什么想法吗?
配置:ADT 22.6.2、NDK r9d(64 位)、OSX 10.9.2
经过一番与偏好的斗争后,我终于找到了解决方案。这是一个bug https://code.google.com/p/android/issues/detail?id=33788在 NDK 插件中,已向 AOSP 报告但尚未修复。评论#50 中描述了答案的过去。这是对我有用的顺序。
- Open 项目属性 -> C/C++ 构建 -> 工具陈编辑器
- 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.
-
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
Press OK按钮,clean and re-build该项目。所有错误都必须消失。如果它们留下来,请尝试将它们从Problems再次查看并重新构建项目。
Update:我找到了另一个地方,您可以在其中添加包含文件的路径。然而,它似乎与 Eclipse 版本相关。项目设置 -> C/C++ 常规 -> 处理器包括路径、宏等 -> CDT 用户设置条目 -> 添加。添加上面列出的路径后,就不再有编译问题了。开发又变得有趣了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)