can’t resolve AppCompatActivity –

Development issue/problem:

After renaming the application package, Android Studio displayed the following error: The AppCompatActivity symbol cannot be resolved.

The things I’ve tried:

But nothing helped. The project was created successfully, but I can’t use syntax highlighting.

I used


How can I solve this problem?

Solution 1:

Okay, for anyone who might be tripping over this issue right now: Android Studio is really, really, really weird.

Solution: Go to your build.gradle file and look for appcompat in the dependencies, for example compiling

Edit it to compile

Then click Sync Now in the upper right corner of the editor. All red scribbles should disappear if everything else in your code is correct.

Then go back to your build.gradle and change it to what it was and click Sync Now.

Everything should be fine, assuming you have the latest version of everything or almost everything.

Solution 2:

Let’s start step by step:
first clean project with

Build -> Remove

If that doesn’t work, use your other weapon.

File>Checked Caches/Restart…

But the real problem starts when all the above options don’t work
, so use your final project with your arms closed, go to the project directory and delete


You can reopen your project. It worked for me, and that’s usually a problem when working with VCS. And this problem not only affects the Android component classes, but also the libraries, both of which have the same error.

Solution 3:

I had the same problem, but when I chose the Invalid Cache/Restart option, it worked for me.

Try deleting all assembly files first.

Build -> Remove

If that doesn’t work, try this option.

File -> Invalid Cache/Restart

Solution 4:

If methods such as

Own project

Cleaning Android Studio’s cache

Coverage of the charging station network

Resettlement of FDI

File-> Invalid Cache/Restart

doesn’t work. Use this method to solve your problem.

From the Android studio come

Navigate to the .idea folder of your project.

Delete the .ideemap

Restart Android Studio.

That’s all I’m saying.

Solution no. 5:

The problem could be the import link, try changing it.


import ;


import androidx.appcompat.appCompatActivity ;

Solution no. 6:

That was good enough for me:

First vote

Solution no. 7:

I had the exact same problem a few minutes ago, and I solved it by doing Build > Rebuild Project.

I hope this helps.

Solution no. 8:

Only deleting the entire .gradle folder helped me.

Solution no. 9:

Oddly enough, that’s exactly what worked for me:

  1. Change the implementation to
  2. Go to the → folder Invalid Cache/Restart
  3. Wait until the cradle is synchronized to complete the restart. You will then be prompted to add a Google Maven support repository. Click on the appropriate link and let Gradle resolve the dependencies.
  4. The bugs should be gone.

FWIW, in my case, the problem occurred after I moved my Android Studio installation to a new machine and upgraded to AS 3.1.

Solution no. 10:

Deleting the .idea file helped me. As Vikas Kumar said.

I then use it to correct the location error of the SDK.

Good luck!

Related Tags:

cannot resolve method v7,class file for android-support v7 app appcompatactivity not found,dependencies for import android support v7 app appcompatactivity,cannot resolve v7 import android support v7 app appcompatactivity,import android support v7 app appcompatactivity import android support v7 app appcompatactivity,capacitor class file for androidx appcompat app appcompatactivity not found,cannot resolve symbol appcompat,import unused import statement,appcompatactivity cannot resolve symbol r,androidx appcompat app appcompatactivity is invalid

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top