当我输入actionbarsherlock进口.R不能得到解决 [英] import .R cannot be resolved when I import actionbarsherlock

查看:180
本文介绍了当我输入actionbarsherlock进口.R不能得到解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用操作栏在我的Andr​​oid项目(2.3),所以我想导入actionbarsherlock库。不过,我有问题....

我已经导入库,编辑我的Andr​​oid项目的构建路径,包括图书馆,并且还删除了Android的支持-V4罐从ABS / libs目录并复制我的项目的Andr​​oid支持-V4进入ABS / libs目录解决罐子不匹配。但是,现在,我已经做了所有这些事情,我的项目无法解析myproject.R任何地方。我导入几乎我所有的.java文件myproject.R,他们都有同样的错误(进口com.myproject.R无法解析)。此外,当我清理我的项目,我得到了很多的错误,在控制台窗口:

他们都走的路线:

  

错误:错误检索父项:未发现的资源匹配给定名称机器人:Theme.Holo.Light。

据我所知,R是所有布局信息存储,所以我不知道为什么这是连一个问题...

我一直对这个错误的天,我感到非常沮丧,最后决定把它栈溢出。谢谢你们的帮助!

解决方案
  

编辑我的Andr​​oid项目,包括库的构建路径

切勿手动修改Android项目的构建路径

ActionBarSherlock是一个Android库项目。您需要 从主要添加的引用ActionBarSherlock的库项目应用项目,并撤消手动更改到构建路径。


更新

你的问题的后半部分是您的构建目标定得太低。构建目标控制什么版本的安卓类,资源等提供给您的应用程序,如果你使用ActionBarSherlock,你需要这是API级别14或更高。

  

如果我做我的项目建设目标4.0,可我还是在一个仿真器/手机中运行它运行Android 2.3?

是的。设置你的安卓的minSdkVersion 是10或更低。日食(通过林特)会骂你,如果你不小心尝试使用类,方法,和这样的,比你的的minSdkVersion ,即使他们是合法的,由于您的构建目标更高

I want to be able to use the action bar in my android project (2.3), so I am trying to import the actionbarsherlock library. However, I am having problems....

I've imported the library, edited the build path of my android project to include the library, and also deleted the android-support-v4 jar from the ABS /libs directory and copied my project's android-support-v4 into the ABS /libs directory to solve the jar mismatch. However, now that I've done all those things, my project can't resolve myproject.R anywhere. I import myproject.R in almost all of my .java files, and they all have the same error ("The import com.myproject.R cannot be resolved"). In addition, when I clean my project, I get a lot of errors in the console window:

They all go along the lines of:

error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.

To my knowledge, R is where all of the layout information is stored, so I have no idea why this is even a problem...

I've been working on this error for days, and I'm extremely frustrated and finally decided to take it to stack overflow. Thanks guys for the help!

解决方案

edited the build path of my android project to include the library

Never manually modify the build path of an Android project.

ActionBarSherlock is an Android library project. You need to add a reference to ActionBarSherlock's library project from your main application project and undo the manual change to the build path.


UPDATE

The second half of your problem was that your build target was set too low. The build target controls what version of the Android classes, resources, etc. is available to your app, and if you use ActionBarSherlock, you need this to be API Level 14 or higher.

if I make my project build target 4.0, can I still run it on an emulator/phone running Android 2.3?

Yes. Set your android:minSdkVersion to be 10 or lower. Eclipse (via Lint) will yell at you if you accidentally try using classes, methods, and such that are higher than your minSdkVersion, even though they are legal due to your build target.

这篇关于当我输入actionbarsherlock进口.R不能得到解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆