project structure, right click on src folder->Mark directory as-> sources root.
Now your mainactivity.java file with 'j' symbol to change to 'c' symbol.
The error was that the project did not have a valid source folder from where it could look for the activity class.