Java 无法构建android项目,因为ActionBarActivity无法解析为类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24912589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 15:34:27  来源:igfitidea点击:

Can't build android project because ActionBarActivity cannot be resolved to a type

javaandroideclipseandroid-support-library

提问by Mitulát báti

I'm following the training on the developer.android.com site and when I arrived at the Building your first app / Starting another activity section I failed:

我正在关注 developer.android.com 网站上的培训,当我到达构建您的第一个应用程序/启动另一个活动部分时,我失败了:

I've added the android-support-v7-appcompat library according to this site describes: http://developer.android.com/tools/support-library/setup.html#libs-with-res

我根据本网站的描述添加了 android-support-v7-appcompat 库:http: //developer.android.com/tools/support-library/setup.html#libs-with-res

Where I select the libraries for an android project (Properties of the project / Android / Library) I clicked the add button, selected the project library (first picture), and after I pressed ok the project didn't build.

在我为一个 android 项目选择库的地方(项目的属性/Android/库)我点击了添加按钮,选择了项目库(第一张图片),在我按下确定后项目没有构建。

Before (everything is ok) Before click ok

之前(一切正常) 点击确定前

After Somehow it failed when I ok'd the window.

当我确定窗口时,它以某种方式失败了。

Before all this... I was somehow able to build the project, press the Play, but it unfortunately stopped (crashed) on my device immediately after starting. And the console said:

在这一切之前......我以某种方式能够构建项目,按下播放,但不幸的是它在启动后立即在我的设备上停止(崩溃)。控制台说:

[2014-07-23 15:06:45 - android-support-v7-appcompat] Could not find android-support-v7-appcompat.apk!

and that was the point when I started investigating the problem... yet unsuccessfully.

这就是我开始调查问题的时候……但没有成功。

My question is, why "deactivating" the library after I check again?

我的问题是,为什么在我再次检查后“停用”图书馆?

采纳答案by Horyun Lee

The library project should be placed on the same drive with your workspace. the referencing project was in the same eclipse workspace as the library project.

库项目应与您的工作区放在同一驱动器上。引用项目与库项目位于同一 Eclipse 工作区中。

回答by ChristianCuevas

You should make a copy of appcompat-v7 and put it in your workspace, then have all the projects just reference it.

您应该制作一份 appcompat-v7 的副本并将其放入您的工作区,然后让所有项目都引用它。

回答by dbug

I had the same problem : using GIT, my project was located on a server :

我遇到了同样的问题:使用 GIT,我的项目位于服务器上:

\BOB\Volume_1\GIT\Android\ICS
\BOB\Volume_1\GIT\Android\ICS

So i had to create a clone of my GIT repository on the same drive than my worspace :

因此,我必须在与 worspace 相同的驱动器上创建我的 GIT 存储库的克隆:

D:\WSpaces\Android -> my workspace where is located android-support-v7-appcompat
D:\WSpaces\GIT     -> the GIT clone repository
D:\WSpaces\Android -> my workspace where is located android-support-v7-appcompat
D:\WSpaces\GIT     -> the GIT clone repository

I probably could have shared the android-support-v7-appcompaton my repository, not tested...

我可能已经在我的存储库中共享了android-support-v7-appcompat,未测试...