Open In App
Related Articles

Different Ways to fix Cannot resolve symbol ‘AppCompatActivity’ in Android Studio

Like Article
Save Article
Report issue

When you create a project and extends activity AppCompatActivity, sometimes you must have observed Android Studio throws an error that is:

Cannot resolve symbol ‘AppCompatActivity’

and this error doesn’t go away easily. In this article, we are going to cover topics: why there is a need to solve this error and five different ways to get rid of this error.

Why There is a Need To Solve “Cannot resolve symbol ‘AppCompatActivity'”?

When you rename the application package name this error pops up. The import statement turns gray and says there’s no package for Even after upgrading to appcompat-v7:22.1.0, in which AppCompatActivty (To get the most out of the Android Support Library that is, to get the latest features supported across the highest number of devices, we need AppCompatActivity) is added, the problem doesn’t go away. So we need to try the following methods to fix this problem in Android Studio.

How To Solve “Cannot resolve symbol ‘AppCompatActivity'”?

Method 1

  • Go to your build.gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile ‘’, change it to compile ‘’ or else hit ALT + ENTER on both appcompat & design dependencies then select the shown version.
  • Then click on Sync.

Method 2

Navigate to File > Invalidate Caches/Restart and then disable offline mode and sync.

Method 3

Step 1: Delete the .idea folder. For .idea folder navigate to YourProject > app > .idea

Step 2: Close and reopen the project

Step 3: File > Sync Project With Gradle Files

Method 4

  • Exit Android Studio and reopen it.
  • Navigate to the .idea folder in your project
  • Just Rename the libraries folder
  • Restart Android Studio. It should now recreate the libraries folder and work again.

Method 5

If you have added AndroidX support in file (that is android.useAndroidX=true and android.enableJetifier=true and if you are using gradle version greater than 3.2),the conventional Appcompat dependency (implementation ‘’) Replace this dependency with: implementation ‘androidx.appcompat:appcompat:1.1.0’. Moreover, change the AppCompatActivity import in your class file from this:


to this


Last Updated : 09 Nov, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads