R 使用 ActionBarSherlock 时无法解决错误
我正在尝试使用 Jake Wharton 的 ActionBarSherlock 来支持 Android 项目中的操作栏,一直到 1.6
我正在开始使用视频 faq 页面 上提供,但在视频 2:25 之后,当他导入项目时,我得到了超过 200 个编译器错误的庞大列表,主要是处理一些 @override 的东西。我通过以下方式修复了大部分错误:
右键单击项目>属性>Java编译器>编译器合规级别:并将其设置为1.6。
这迫使我重新构建,突然间我的错误数量减少到只有 54 个。其中大多数是“R 无法解析为变量”,但最后 5 个都是“无法解析 import com.actionbarsherlock.R”。我进行了搜索,解决此问题的常见方法如下:
“确保您的资源没有错误” - 我检查了 /res 文件夹中的任何内容都没有问题
“ 确保您没有导入 android.R”——我没有。我有:
import com.actionbarsherlock.R
我想到包名称可能不正确,但事实并非如此。
“简单地清理项目” - 已经这样做了很多次了,但没有效果
“确保 eclipse 能够生成 R 文件” - 它可以在空白中我刚刚制作的测试项目
还有一些更具体到 ActionBarSherlock 的其他修复:
“确保您的 targetSDK 为 11 或更高” - 它设置为 13
“确保项目是一个图书馆项目”——就是
这样我可以摆脱这些错误吗?
I am trying to use Jake Wharton's ActionBarSherlock to support actionbars in android projects all the way down to 1.6
I'm getting started using the video provided on the faq's page but after 2:25 in the video, when he imports the project, I get a whole huge list of >200 compilers errors, mostly dealing with some @override stuff. I fix most of those errors by:
Right click on the project>properties>Java Compiler>compiler compliance level: and I set it to 1.6.
This forces a re-build and suddenly I am down to just 54 errors. Most of them are "R cannot be resolved to a variable" but the last 5 are all "the import com.actionbarsherlock.R cannot be resolved". I have searched around and the common ways of solving this worked out as follows:
"Make sure your resources are not in error" -- I checked and there are no problems with anything in the /res folder
"Make sure you aren't importing android.R" -- I am not. I have:
import com.actionbarsherlock.R
It occurred to me that the package name might be incorrect, but it isn't.
"Simply clean the project" -- Have done this many times to no effect
"Make sure eclipse is able to generate R files at all" -- It can in the blank test project I made just now
And some other fixes which are more specific to ActionBarSherlock:
"Make sure your targetSDK is 11 or higher" -- It is set to 13
"Make sure the project is a library project" -- It is
How can I get rid of these errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
找到了!
而不是:
项目>清洁>清理下面选择的项目,
您必须使用
项目>清洁>清理所有项目
即使其他项目与库项目没有任何关系。这解决了问题
Found it!
Instead of:
Project > Clean > Clean Projects Selected Below
you must use
Project > Clean > Clean All Projects
Even if none of the other projects have anything to do with the library project. This fixed the problem
我的错是 ABS 项目和我的项目有不同的 API 级别。 ABS 的级别为 4.0.3,而我的项目为 3.0。将我的项目的 API 级别更改为 4.0.3 后,所有错误均已修复。这篇帖子帮助我找到了解决方案。
My fault was, that the ABS-project and my project had different API levels. ABS was on level 4.0.3 and my project had 3.0. After changing the API level of my project to 4.0.3 all errors were fixed. This post helped me to find the solution.
可能还需要确保为正确的包名称创建 nen/R.java 文件:
在 AndroidManifest.xml 上,确保清单标记的 package 属性设置为:
Might also need to make sure your nen/R.java file is created for the right package name:
On AndroidManifest.xml, make sure the manifest tag, package attribute is set to:
我最终没有导入单个文件夹 actionbarsherlock,而是选择了父文件夹并在“导入项目”窗口中取消选中除 actionbarsherlock 之外的所有内容。
Instead of importing the single folder actionbarsherlock, I ended up picking the parent folder and unchecked everything but actionbarsherlock in the Import Projects window.
我的不同:
我有一个 64 位操作系统(linux mint),我必须安装 32 位库:
之后只需清理所有内容并构建一个新项目,它就可以工作了。
Mine was different:
I have a 64bits OS (linux mint) and I had to install the 32bit libraries:
After this just clean all and build a new project and it worked.
R
文件未创建时,您应该首先尝试:ActionBarSherlock
应该至少为 14 或更高版本:R
file not created you should first try:ActionBarSherlock
: