0

I'm getting the error "Cannot resolve the symbol ActionBarActivity" when I try to import it (import android.support.v7.app.ActionBarActivity;).

I've already read some questions ActionBarActivity cannot resolve a symbol and Import Google Play Services library in Android Studio about it and i've tried the solution described there but I couldn't fix my problem. I tried to change the targetSdK to one lower and then I wrote back that that I had before but it didn't resolve.

I'm using Android Studio version 1.0.2.

My build.grad file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.android.asminhasdespesas"
        minSdkVersion 13
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

My Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.asminhasdespesas" >

    <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="21"></uses-sdk>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Do you have any possible resolution to fix this issue since I think this shouldn't happen with this Android Studio version. Thanks.

Community
  • 1
  • 1
porthfind
  • 1,581
  • 3
  • 17
  • 30

2 Answers2

0

Looks like you're missing this import in the activity:

import android.support.v7.app.ActionBarActivity;

You can fix this by using ctrl + alt + o. A project rebuild might also do the trick.

Santiago Aceñolaza
  • 276
  • 1
  • 2
  • 11
  • I'm sorry I didn't understand your answer. When I try to **import android.support.v7.app.ActionBarActivity;** on my MainActivity I got that error. – porthfind Feb 17 '15 at 23:46
  • My bad. I was just working with Android Studio while I read your question so I went to an activity I had opened and removed the import and I then saw that same error "Cannot resolve the symbol ActionBarActivity". Did you try to go to **Build -> Rebuild Project**? I'm pretty sure you need to do that after adding the 'compile' dependency in build.gradle. As a side note, I always add the compile dependency for appcompat on my module build.gradle and not in the global gradle file. – Santiago Aceñolaza Feb 18 '15 at 01:08
0

I tried to refresh Gradle and it seemed to work! Maybe some instant problem with android studio and gradle synchronization!

arniotaki
  • 2,175
  • 2
  • 23
  • 26