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

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


If you use androidX instead of android, you need change

import android.support.v7.app.AppCompatActivity;

to

import androidx.appcompat.app.AppCompatActivity;

and change

<android.support.constraint.ConstraintLayout>

to

<androidx.constraintlayout.widget.ConstraintLayout>

1.Delete the .idea folder
2.Close and reopen the project
3.File - > Sync Project With Gradle Files

This worked for me