Cannot resolve symbol AppCompatActivity - Support v7 libraries aren't recognized?

hendersawn picture hendersawn · Jun 12, 2015 · Viewed 187.6k times · Source

I'm trying to figure out why the heck my Android studio isn't recognizing the AppCompat v7 library correctly. The import statement below shows up as gray and says there's no package for support.v7.app. Below is my activity file:

import android.support.v7.app.AppCompatActivity;


public class XApplicationActivity extends AppCompatActivity

My build.grade:

compile "com.android.support:appcompat-v7:22.0.0"
compile "com.android.support:support-annotations:$ANDROID_SUPPORT_VERSION"
compile "com.android.support:support-v4:$ANDROID_SUPPORT_VERSION"

My project settings:

minSdkVersion = 14
targetSdkVersion = 21
compileSdkVersion = 21
buildToolsVersion = "22.0.1"

So I'm really confused as to why this is still giving me issues. Things I've tried already:

  • Cleaning/rebuilding the project
  • Invalidating caches and restarting
  • Checking a billion times to make sure I have the support library installed (I absolutely do have the latest support repository and libraries installed)

Anybody know of any fixes? It's cost me a lot of time and it's really frustrating.

Answer

Nicks picture Nicks · Jun 22, 2015

For me, Even after upgrading to appcompat-v7:22.1.0, in which AppCompatActivty is added, the problem was not resolved for me, Android Studio was giving same problem

Cannot resolve symbol 'AppCompatActivity'

Sometimes clearing the android studio caches help.

In android studio I just cleared the caches and restarted with the following option--

File->Invalidate Caches/Restart