can't resolve AppCompatActivity

2019-01-16 14:07发布

After renaming application package name, Android Studio displayed this error can't resolve symbol AppCompatActivity

Things I tried:

  • Clean project
  • Clean Android Studio cache
  • Clean Gradle cache
  • Re-installed IDE
  • File-> Invalidate cache/restart

But nothing really helped. The project build successfully, but I can not use syntax highlighting.

I used com.android.support:appcompat-v7:23.1.1

Screenshots

BaseActivity

Build gradle file

29条回答
该账号已被封号
2楼-- · 2019-01-16 14:43

I had the same issue and the following worked for me

File -> Invalidate cache/Restart

There is some kind of caching issue that is happening. If such kind of issue appears try this since most of the time it will work :D

查看更多
Lonely孤独者°
3楼-- · 2019-01-16 14:44

With the new Release of android studio 3.1.3, you must put this code inside build.gradle.

implementation 'com.android.support:design:23.4.0'
查看更多
Viruses.
4楼-- · 2019-01-16 14:46

I've updated appcompat library from version 25.0.1 to 25.1.0

In gradle:

from: com.android.support:appcompat-v7:25.0.1

to: com.android.support:appcompat-v7:25.1.0

Everything works well now.

查看更多
Emotional °昔
5楼-- · 2019-01-16 14:48

For me was enough to go on: - Tools > ANDROID > SYNC PROJECT WITH GRADLE FILES

The first voice

查看更多
狗以群分
6楼-- · 2019-01-16 14:50

Lets get going step by step: first clean project by using

Build->Clean

if this doesn't helps then use your second weapon

File>Invalidate Caches/Restart...

But the real problem begins when all the above options doesn't works so use your ultimate weapon close project and go to project location directory and delete

.idea

You can open your project now again. This worked for me and problem comes most often when you are working with VCS. And this problem is not associated with android component classes but also to the libraries, both shows the same error.

查看更多
老娘就宠你
7楼-- · 2019-01-16 14:51

If all attempts failed (invalidate cache, clean and rebuild, restart,...), close Android Studio (maybe just close the project), run any file manager, go to project folder, find .idea/libraries folder and delete its content (list of xml files). After new start AS or opening project the problem should be resolved.

查看更多
登录 后发表回答