1

Error says:

This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
The following classes could not be found: item and menu

img1

And why is the java class for that layout is showing plenty of "Cannot resolve symbol R"?

img2

I'm not sure why the xml file and java class are not compiling. I appreciate any feedback from you guys.

J03L
  • 314
  • 3
  • 17
agentmg123
  • 17
  • 7

1 Answers1

1

You cannot have a layout of a menu inside the layout of an activity. It must be defined separately in an XML file inside the res/menu/ directory, in a similar way as your main_options_menu.xml file is defined.

The reason for getting the cannot resolve symbol R error is because the Gradle build did not complete (due to an error). To fix it, either build or clean the project after removing all errors. You may check out "cannot resolve symbol R" in Android Studio.

Community
  • 1
  • 1
Faheel
  • 2,435
  • 24
  • 33