Android的/日食 - 进口别人的项目时的错误 [英] Errors when importing someone else's projects - Android/Eclipse

查看:155
本文介绍了Android的/日食 - 进口别人的项目时的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Eclipse约6个月,我发现我很少可以导入别人的项目导入Eclipse。我在很多文件中得到如此多的错误。例如,我试图导入一个朋友的项目,我知道的作品不错,但我得到了很多的R的错误,比如Eclipse无法识别R作为一个字段,然后其他古怪的像ActionBarActivity不认可或整个进口喜欢android.support.v4.app.Fragment在视觉上是在库但不被认可的Eclipse作为当时在那里,我检查他们,他们肯定是标有是图书馆,并补充适当的项目。任何人都知道这是为什么或如何解决?这是令人沮丧,因为学习,有时你需要看别人的应用程序运行,再看看自己的code,但你不能。先谢谢了。

I have been using Eclipse for about 6 months now, and I noticed that I rarely can import someone else's project into Eclipse. I get so many errors in many files. For example, I tried to import a friend's project that I know works just fine, but I get a lot of "R" errors, like Eclipse can't recognize "R" as a field, and then other weird ones like ActionBarActivity is not recognized or an entire imports like android.support.v4.app.Fragment that visually are in the library but are not being recognized by Eclipse as being there, and I check them and they are definitely marked "Is library" and added properly to the project. Anyone know why this is or how to fix? It's frustrating because to learn, sometimes you need to see someone else's app run first, then look at their code, but you can't. Thanks in advance.

我通常导入项目的方法是做文件 - >导入 - >常规 - >现有项目到工作区。另外,我试图清洗的项目,但它不工作

My usual way of importing a project is to do File -> Import -> General -> Existing Projects into Workspace. Also, I have tried cleaning the project, but it doesn't work.

推荐答案

所以,感谢这个帖子大家的帮助下,和其他人在另一篇文章,问题终于固定的,采取了几个步骤。

So thanks to the help of everyone of this post, and others on another post, the problem was finally fixed and took several steps.


  1. 原来,ActionBarActivity错误有一个快速修复(将鼠标悬停在它,你就会得到快速修复选项)导入appcompat_v7库。我从来没有选择之前,因为我认为它已经安装了,所以与Android支持-v4.jar(即有该库的双打)的冲突,但我还是选择了反正导入和错误走了。

  1. Turns out that the ActionBarActivity error had a quick fix (hover over it, you get quick fix options) of importing the appcompat_v7 library. I never chose that before, because I thought it was already installed, hence the conflict with android-support-v4.jar (meaning there were doubles of that library), but I chose to import it anyway and that error went away.

不过,我发现,Android的支持,v4.jar竟是appcompat_v7的一个组成部分,所以这是导致不匹配罐子!错误在控制台中。所以我删除了Android的支持 - 从v4.jar libs文件夹,并罐子不匹配就走开了。

But I discovered that android-support-v4.jar was actually a component of appcompat_v7, so that was causing the "Jar mismatch!" error in the console. So I deleted android-support-v4.jar from the libs folder, and the jar mismatch went away.

最后,我的布局文件都是不被认可,即使我知道变量名是正确的。所以是错误的,当我试图刷新我的进口问题的开始(用SHIFT +指令+ O),认为它是一个导入的问题(这是),但在那个时候,刷新什么也没做。但是... Eclipse中拿走了进口 com.laurengariepy.android.gridimagesearch.R; android.R取代它; ,这是什么导致所有的布局错误。所以一旦我把 com.laurengariepy.android.gridimagesearch.R; 回来了,那么所有的错误,走了

Lastly, my layout files were all not being recognized, even though I knew the variable names were all correct. So the error was from when I tried to refresh my imports in the very beginning of the problem (using shift+command+O), thinking it was an import problem (which it was), but at that time, refreshing did nothing. BUT... Eclipse took away import com.laurengariepy.android.gridimagesearch.R; and replaced it with android.R;, which is what was causing all the layout errors. So once I put that com.laurengariepy.android.gridimagesearch.R; back, then all errors went away.

因此​​外卖这个故事,是要小心的Eclipse版本22.6。在appcompat_v7库的自动导入会造成很多麻烦,当您尝试导入其他人的项目,因为他们可能不符合appcompat_v7已经有一个IDE创建的。

So the take-away to this story, is be careful with Eclipse version 22.6. The auto-import of the appcompat_v7 library will cause a lot of trouble when you try to import other people's projects, because they were likely not created in an IDE with appcompat_v7 already there.

这篇关于Android的/日食 - 进口别人的项目时的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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