Android Studio Unresolved reference: activity_main – R.layout and R.id

You can easily run into mysterious errors with Android Studio. Here is one.

Suddenly all references related to R.layout or R.id stopped to work and build failed with a message like this:

The code looked like this:

I tried clean, builds, rebuilds. Nothing helped. The problem was caused by simple import which accidentally occurred in Activity file:

After removing this line the whole project was working again and even code hinting was correct.