0

I have import info.dodata.mirror.R, I always get the warning information Unresolved reference: R when I reopen a project for the first time, just like the following image.

I have to click the menu Build -> Rebuild project to rebuild the project, or I close the project and reopen it again in Android Studio 3.1.1 to resolve the problem.

Both my office PC and home PC with windows 7 x64 meet the same problem. How can I fix it? Thanks!

Image

enter image description here

To ice1000:

Thanks! Do you mean that I should click Refresh All Gradle Projects button? enter image description here

HelloCW
  • 843
  • 22
  • 125
  • 310

1 Answers1

2

Because R.java is generated from your resource xml files, and it's not always there. It takes few seconds to get generated.

I don't know how Android Studio resolves that file, but it's also possibly just a dummy file which is not there when you're not compiling your code. So it's quite normal to see unresolved reference in the very beginning when AS load your project.

To quickly get your project refreshed you may need refresh your project instead of rebuild it:

Wow

If you can't find that button, try pressing Ctrl+Shift+A, you'll see a popup, and you can search refresh:

enter image description here

ice1000
  • 6,406
  • 4
  • 39
  • 85