Android的错误:无法找到符号类ActionBarActivity [英] Android error: cannot find symbol class ActionBarActivity

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

问题描述

我目前使用Android的工作室(测试版)0.8.6,当我尝试运行一个应用程序到我的设备,将出现以下错误:

I am currently Using Android Studio (Beta) 0.8.6 and when I try to run an app into my device, the following error appears:

 error: cannot find symbol class ActionBarActivity

我抬头对这个错误的解决方案,并发现了以下几点:
<一href=\"http://stackoverflow.com/questions/24382959/cannot-find-symbol-actionbaractivity-following-android-development-tutorial\">Link

可惜我不是的Eclipse下。

Unfortunately I am not under Eclipse.

在code我尝试运行如下:

The code I try to run is the following:

package com.example.doblevxv5.sunny;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

/**
 * Created by Doble Vx V5 on 8/11/14.
 */
public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new ForecastFragment())
                    .commit();
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}

我与API 17.运行Android 4.1.2
你有什么建议家伙?

I am running with API 17. Android 4.1.2 Do you have any suggestion guys?

谢谢!

推荐答案

在你的的build.gradle 添加以下在依赖行块:

compile 'com.android.support:appcompat-v7:21.0.+'

另外,还要确保有 compileSdkVersion targetSdkVersion 下的设置为 21 机器人块。

然后同步您的项目。如果 AUTOIMPORT 已禁用 - 添加此输入:

Then Sync your project. If autoimport is disabled - add this import:

import android.support.v7.app.ActionBarActivity;

另外需要更新的Andr​​oid Studio和gradle这个插件的最新版本。

Also update Android Studio and gradle plugin to the latest version.

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

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