我有一个带有本机代码的Android项目。我可以通过调用ndk-build
command来从命令行构建本机代码,而不会出现任何错误或警告。但是,当我在ADT中打开它时,它显示以下错误。
错误消息:项目中Method CallStaticIntMethod could not be resolved.
有许多文件具有相似的错误。
我仔细检查了配置,这就是我所拥有的。Android构建,工具链和包含项已正确配置(请参见下图)
必需的包含项在Project Explorer中也可见,并且它们是有效的(不是空的并且指向正确的头文件)。
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.
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
按确定按钮,清理并重新生成项目。所有错误都必须消除。如果它们仍然存在,请尝试从“问题”视图中将其删除,然后再次重新构建项目。
更新:我找到了另一个地方,您可以在其中添加包含文件的路径。但是,它似乎与Eclipse版本有关。项目设置-> C / C ++常规->处理器包含路径,宏等。-> CDT用户设置条目->添加。添加上面列出的路径后,不再有编译问题。开发再次变得有趣。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句