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

Jyotishgher Astrology
By -
0

Cannot resolve symbol ‘AppCompatActivity’ 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 ‘com.android.support:appcompat-v7:XX.X.X’, change it to compile ‘com.android.support:appcompat-v7:XX.X.+’ 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 Gradle.properties file (that is android.useAndroidX=true and android.enableJetifier=true and if you are using gradle version greater than 3.2),the conventional Appcompat dependancy (implementation ‘com.android.support:appcompat-v7:27.1.1’) Replace this dependancy with: implementation ‘androidx.appcompat:appcompat:1.1.0’. Moreover, change the AppCompatActivity import in your class file from this:

import android.support.v7.app.AppCompatActivity

to this

import androidx.appcompat.app.AppCompatActivity

Post a Comment

0Comments

Post a Comment (0)