Home » Android » Cannot resolve symbol 'AppCompatActivity'

Cannot resolve symbol 'AppCompatActivity'

Posted by: admin November 30, 2017 Leave a comment

Questions:

I’ve just tried to use Android Studio. I’ve created blank project and tried to create Activity which extends AppCompatActivity. Unfortunalty Android Studio “says” that it

Cannot resolve symbol ‘AppCompatActivity’

I have compile "com.android.support:appcompat-v7:22.0.+" in dependency list of my “app” module and rebuilt project several times. However I can only use ActionBarActivity. What am I doing wrong?

Answers:

However I can only use ActionBarActivity.

Correct. For the appcompat-v7 library, that is the base class to use for your activities when you want to add an action bar.

What am I doing wrong?

Trying to use a class that doesn’t exist. 🙂

Questions:
Answers:

A little addition to other answers here, for anyone having the same error while using the right lib version and the right class.

When I upgraded to appcompat-v7:22.1.0, in which ActionBarActivity is deprecated and empty and AppCompatActivty is the way to go, due to some glitch in Android Studio, it didn’t quite pick up on version change. I.e. even though Gradle ran without errors, the IDE itself kept saying Cannot resolve symbol 'AppCompatActivity' (and it also wasn’t available through the Ctrl+N search)

I looked into the .idea/libraries folder and noticed there’s no appropriate metafile for the new version of the lib.

So, using the old-reliable File->Invalidate Caches/Restart did the trick. Always try this when you feel something is magically wrong with Android Studio.

Questions:
Answers:

Today (22 April) you can use the new AppCompatActivity released with the support libraries v 22.1.0.

Just change your dependency :

compile "com.android.support:appcompat-v7:22.1.0"

Here you can find more info about this new class.

Questions:
Answers:

Check for typos too, i wasted my whole day looking for solutions when i had actually typed AppCompactActivity instead of AppCompatActivity

Questions:
Answers:

Try this. In Android Studio, after putting the dependency in build.gradle.
Go to Build –> Clean Project.

It worked for me.

Questions:
Answers:

I got it fixed by Going to build.gradle file and in dependencies the appcompat one, something like compile 'com.android.support:appcompat-v7:XX.X.X'

Changed it to compile 'com.android.support:appcompat-v7:XX.X.+'

Then click on Sync. All the red squiggly lines should go if everything else in your code is correct.

Questions:
Answers:

You can use new AppCompatActivity appcompat-v7:22.1.+
Just add this to your gradle:

compile ‘com.android.support:appcompat-v7:22.1.1’

Questions:
Answers:

I was getting this same problem with Android SDK 23, while developing on a Mac OS X Yosemite Machine. It turned out that I did not have Java SDK 7.

Once I installed Java SDK 7 and pointed the SDK from with the Android Studio to the new SDK, everything worked for me.

Here are the steps that I followed:

1) Shutdown Android SDK

2) Install Java SDK for Mac OS X from http://www.oracle.com/technetwork/java/javase/downloads/index.html

3) Start the Android SDK and point the SDK for this project to the new 1.7 Java SDK by going to File -> Project Structure -> JDK Location

4) Restart Android Studio

Hope this help

Questions:
Answers:

I got the Cannot resolve symbol error for AppCompatActivity and many other classes & methods after updating Android Studio from 2.2.3 to 2.3, updating Android Gradle plugin to 2.3.0, and updating Gradle to 3.3.

File -> Invalidate Caches / Restart did not resolve the issue.

Preferences -> Build, Execution, Deployment -> Gradle showed Use local gradle distribution selected with Gradle home: /Applications/Android Studio.app/Contents/gradle/gradle-2.14.1 and a warning displayed saying the gradle location was incorrect.

Resolved issue by selecting Use default gradle wrapper (recommended).
Probably just pointing to the new local distribution location would also work.

Questions:
Answers:

For me the issue resolved when i updated the appcompact v7 to latest..

compile ‘com.android.support:appcompat-v7:25.3.0’

Hope it helps…:)

Questions:
Answers:

After upgrading to the latest support library, I had to upgrade to the latest Android studio (beta) version and gradle version before the IDE recognized AppCompatActivity again (invalidating caches and restart did not do the trick)

Questions:
Answers:

Remember to press Alt+Enter or add the import.

import android.support.v7.app.AppCompatActivity; 

Questions:
Answers:

For me, the issue resolved when I updated the Gradle build version. Don’t know why?

Questions:
Answers:

I’ll tell you how did i solved this problem in eclipse.
Download zip file from this link.https://github.com/dandar3/android-support-v7-appcompat then extract this file,open project, in lib folder you will see one jar file named “android-support-v7-appcompat” , add this jar file into your project. Thats it. enter image description here

Questions:
Answers:

This can might be in the version difference in the app level gradle check it once and then re-build

Questions:
Answers:

Add this dependency in project build .gradle.

Follow the example below.

dependencies {

    compile 'com.android.support:appcompat-v7:22.1.0'
}

Leave a Reply

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