__ANDROID__ 宏突然没有定义 [英] __ANDROID__ macro suddenly not defined
问题描述
我正在开发一个使用 NDK 的应用程序(我所写的所有内容都发生在 r6b 和 r8d 上)
I'm working on an app which uses NDK (all I'm writing happened both on r6b and r8d)
一切正常,我想开始尝试调试我的 C 代码.
Everything was working fine, and I wanted to start and try debugging my C code.
我遵循了这个 http://tools.android.com/recent/usingthendkplugin 教程,但是 NDK_DEBUG = 1
标记到我的构建命令,突然我开始在代码中遇到错误,即使删除该标记后也没有消失,从 Android 4.2.2 更改回 2.2,更改 NDK我正在使用,或者我能想到的任何其他东西.
I followed this http://tools.android.com/recent/usingthendkplugin tutorial,
but NDK_DEBUG = 1
tag to my build command, suddenly I started getting errors in the code which didn't go away even after removing that tag, changing from Android 4.2.2 back to 2.2, changing the NDK I was using, or anything else I could think of.
问题现在发生在这样的语句中
The problems happens now inside statements like this
#ifdef __ANDROID__
some cool android code
#else
some pretty awesome iOS code
#endif
__ANDROID__
出于某种原因未定义会发生什么,导致 eclipse 和 ndk-build
尝试编译 iOS 代码而不是 Android 代码
what happens it that the __ANDROID__
is for some reason not define, causing eclipse and ndk-build
to try and compile the iOS code instead of the Android's
还原我所做的一切似乎没有任何效果.重新启动eclipse也没有.清理项目,彻底删除libs
和obj
目录也没有用..
Reverting everything I did didn't seems to have any effect. Restarting eclipse didn't as well. Cleaning the project, completely delete libs
and obj
directories didn't work too..
有什么建议吗?
谢谢!
也许值得补充的是,使用 ndk-build 成功完成构建本身.我认为这可能是一个日食问题,但即使是这样,它仍然是一个错误,我无法启动应用程序
Maybe it's worth adding that the build itself, using ndk-build completes successfully. I think it might be an eclipse issue, but even if so, it still an error and I can't launch the app
另外,以防万一,重新启动计算机也不起作用.
Also, just in case, restarting the computer didn't work either.
编辑 2:问题存在于通过网络运行相同工作区的另一台计算机上,我猜测与工作区有关,所以我尝试删除 .metadata
文件夹并再次添加项目.
EDIT 2:
The problem exists on another computer running the same workspace over network, my guess was something related to the workspace, so I tried deleting .metadata
folder and adding the project again.
删除 .metedata
文件夹第一次修复了它,但几分钟后(我设法在我的平板电脑上构建和运行该应用程序)返回相同的问题,并删除 <代码>.metadata 不起作用
Deleting the .metedata
folder fixed it the 1st time, but after a few minutes (in which I managed to build and run the app on my tablet) the same issue returned, and deleting the .metadata
didn't work
编辑 3:
还是不行.
但是,我可以确认这不是特定于项目的问题,因为所有在 eclipse 中具有 Native 支持的项目现在都这样做了.
However, I can confirm that it's not a project specific problem, as all the projects that has Native support in eclipse now do this.
其他不起作用的东西:
- 创建一个空项目,添加 Native 支持.
- 完全切换到另一个不相关的工作区并执行上述测试
- 下载新版 eclipse (juno)、
CDT
&ADT
(使用的是 eclipse ADT 包)
- creating an empty project, adding Native support.
- Completely changing to another unrelated workspace and perform the above tests
- Downloading fresh version of eclipse (juno),
CDT
&ADT
(was using the eclipse ADT bundle)
推荐答案
如果其他人遇到这个问题:
If anyone else encounters this issue:
我在另一台计算机上打开了工作区(工作区位于 Dropbox 文件夹中),但问题仍然存在于另一台计算机上,这可能只是工作区问题,因此我从工作区中删除了 .metadata 文件夹.
I opened the workspace on another computer (Workspace is in a Dropbox folder), and the problem was still there on the other computer, which could only mean a workspace issue, so I delete the .metadata folder from the workspace.
我不得不重新添加项目,但这样做之后,现在一切似乎都正常了.
I had to re-add the projects, but after doing so, everything seems to work now.
这篇关于__ANDROID__ 宏突然没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!