Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

android - Android Studio中的“无法解析符号R”(“cannot resolve symbol R” in Android Studio)

In every instance in all of my classes where I reference R.id.something , the R is in red and it says "cannot resolve symbol R".

(在我引用R.id.something所有类的所有实例中, R均为红色,并显示“无法解析符号R”。)

Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentView(?)".

(同样,每次有R.layout.something它都会用红色下划线表示“无法解析方法setContentView(?)”。)

The project always builds fine.

(该项目始终可以正常运行。)

It is annoying to see this all the time.

(一直看到这很烦人。)

I have read many other questions on here about something similar but most involved importing projects from Eclipse.

(我在这里阅读了许多其他问题,这些问题与相似但最涉及从Eclipse导入项目有关。)

I am using what I believe to be the most recent version of Android Studio and the project was created with Android Studio and worked without any "cannot resolve R" problems.

(我使用的是我认为是Android Studio的最新版本,并且该项目是使用Android Studio创建的,并且可以正常工作而没有任何“无法解决R”问题。)

I would like to know what causes this if anyone knows.

(如果有人知道,我想知道是什么原因造成的。)

  ask by ez4nick translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had this this issue too.

(我也有这个问题。)

A simple 'gradlew clean' and 'gradlew build' did the trick.

(一个简单的“ gradlew clean”和“ gradlew build”就可以解决问题。)


Click on Build->Clean Project and that will perform a gradle clean

(点击Build- > Clean Project ,这将执行gradle clean)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...