ActionBarActivity 无法解析符号 [英] ActionBarActivity cannot resolve a symbol

查看:30
本文介绍了ActionBarActivity 无法解析符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 android Studio 中,编译器无法定位 ActionBarActivity.正因为如此,我收到了很多错误.编译器无法导入 ActionBarActivityActionBar 类.这些是编译器抛出错误的行:

In my android Studio, Compiler is not able to locate ActionBarActivity. Because of it, I am getting many errors. The compiler is not able to import the ActionBarActivity and ActionBar class. These are the lines where compiler is throwing error:

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;

我在提问之前尝试在 stackoverflow 上搜索.我得到的答案是用于添加库的 eclipse.我尝试在 Android Studio 中执行此操作,但没有得到任何结果.

I tried to search on stackoverflow before asking a question. The answer i got is for the eclipse which is to add the library. I tried doing it in Android Studio, but didn't get anything.

推荐答案

按照上述步骤在 Android Studio(0.4.2) 中使用 support ActionBar :

从 Android SDK Manager 下载 Android Support Repository,Android Studio 工具栏(或 Tools -> Android -> SDK Manager)上将提供 SDK Manager 图标.

Download the Android Support Repository from Android SDK Manager, SDK Manager icon will be available on Android Studio tool bar (or Tools -> Android -> SDK Manager).

下载后,您将在此处找到您的支持存储库

After download you will find your Support repository here

$SDK_DIR\extras\android\m2repository\com\android\support\appcompat-v7

打开主模块的 build.gradle 文件并添加以下依赖项以在较低的 API 级别使用操作栏

Open your main module's build.gradle file and add following dependency for using action bar in lower API level

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}

使用工具栏中提供的微小 Gradle 图标(或 Tools -> Android -> Sync Project With Gradle Files)将您的项目与 gradle 同步.

Sync your project with gradle using the tiny Gradle icon available in toolbar (or Tools -> Android -> Sync Project With Gradle Files).

Android Studio 0.4.2 存在一些问题,因此如果您在代码中导入类时遇到任何问题,请检查这一点.

There is some issue going on with Android Studio 0.4.2 so check this as well if you face any issue while importing classes in code.

在 Android Studio 中导入 Google Play 服务库

如果需要,也请按照以下步骤操作:

If Required follow the steps as well :

  • 退出 Android Studio
  • 从您的文件夹中删除所有 .iml 文件和 .idea 文件夹中的文件项目
  • 重新启动 Android Studio 并等待项目完全同步与 gradle.如果它在带有导入选项的事件日志中显示错误,请单击导入项目.

这是 Android Studio 0.4.2 中的错误,已针对 Android Studio 0.4.3 版本修复.

This is bug in Android Studio 0.4.2 and fixed for Android Studio 0.4.3 release.

这篇关于ActionBarActivity 无法解析符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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