Android Studio 2.1 Cannot resolve symbol 'R'

前端 未结 9 1187
鱼传尺愫
鱼传尺愫 2021-02-10 17:10

Android Studio 2.1, Java V8 Update 91, Gradle 2.1.0 .

I know that this questions has been asked many times here, but none of the recommendation solutions works out.

相关标签:
9条回答
  • 2021-02-10 17:41

    I have just gone through this nightmare. Ended up removing all xml code to notepad until it was fixed. Then reintroduced sections of code until problem appeared. Thinking back, it all started when I pasted some code using WordPad. Apparently WordPad contains a different coding or something so bet to avoid. Anyway just check your white space in xml by deleting it all to rid yourself of any hidden characters.

    0 讨论(0)
  • 2021-02-10 17:44

    If you are using google play services and your compilesdk version is lower than 23 then download the new sdk and update your compile version. After that try cleaning and rebuilding. It will be fixed

    0 讨论(0)
  • 2021-02-10 17:44

    I've seen this problem many times. The right solution is:

    When you type R, the Android Studio will give you many different namespaces for R to choose from, that look like R(***.***.***), but what you really need is the namespace that ends with ***.myProject. (Note: myProject is your project name), e.g: R(com.example.milka.demoProject).

    If you choose any other namespace, you will get the error message, so you have to delete the unneeded import, and re-choose your R

    0 讨论(0)
  • 2021-02-10 17:48

    Try performing a clean and rebuild by going to Build > Clean Project and Build > Make Project

    0 讨论(0)
  • 2021-02-10 17:50

    I try to change the Gradle version from 2.1.0 to 2.0.0, even in AS ver 2.1, ignoring the Instant Run performance and its work out. The little R error is now gone. Now, I tried to change back to 2.1.0, the R error also gone..!! Sometime this little thing drive me crazy, a bit.

    Shame on me.

    0 讨论(0)
  • 2021-02-10 17:58

    Maybe the error may cause for the tools, trying install Android SDK Build Tools from Tools > Android > SDK Manager. or maybe this error can be caused by adding an activity to a namespace that is different to the root, you can trying >>Import com.example.MyApplication.R; or your also can clean o rebuild your project in Build > Clean Project or Build > Rebuild Project

    0 讨论(0)
提交回复
热议问题