安装 Android ADT 14 后:“R 无法解析”
更新到 ADT 14 后,我以前构建良好的项目现在充满了错误。我在任何地方引用“R”(R.string.mystring等)时都会说“R无法解析”。
我没有在任何地方导入 android.R 。
我的“gen”文件夹中没有任何内容。
“清理”项目只是通过用错误标记来显示我引用“R”的所有位置。
有什么建议吗?
After updating to ADT 14, my project which formerly built fine now is full of errors. Everywhere I reference "R" (R.string.mystring, etc.) it says "R cannot be resolved".
I do not have android.R imported anywhere.
There is nothing in my "gen" folder.
"Cleaning" the project just revealed ALL the places I reference "R" by flagging them with an error.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如您所说,该问题通常是由导入
android.R
引起的,但由于这不是您的情况的问题,我怀疑您的资源文件之一中存在 XML 错误。The problem is usually caused by
android.R
being imported, as you state, but since that's not the problem in your case, I'd suspect you've got an XML error in one of your resource files.确保您已安装最新的 ADT Eclipse 插件或/并从“Android SDK 和 AVD 管理器”重新安装 Android SDK 工具 + 平台工具(Eclipse -> 窗口 -> Android SDK 和 AVD 管理器)
Make sure you've installed the latest ADT Eclipse Plug-In or/and reinstall the Android SDK Tools + Platform-Tools from the "Android SDK and AVD Manager" (Eclipse -> Window -> Android SDK and AVD Manager)
我尝试了上述所有技巧,但没有一个对我有用。我的字符串文件中也没有 xml 错误。最终删除并重新创建 strings.xml 对我有用。
I tried all the above tips, but none of them worked for me. There were no xml errors in my strings file either. Ultimately deleting and recreating the strings.xml was what worked for me.
是的,由于 R14 和 R15,可能会发生,我也遇到过它,为了快捷解决方案,尝试更改任何 java 文件,并清理构建 android 项目。这为我创建了 R.java 文件。我知道这不是问题的完美答案,但它有效
Yes could possibly occur due to R14 and R15, i faced it too, for shortcut solution, try to change any java file, and clean build android project. This created R.java file for me. I know its not perfect answer for problem, but it works