I know this is an old question, but I came across it and resolved it. But anyone that runs into this, simply close your project and reopen it. That solved it for me. I'm using Android Studio.
I had the same problem when using Visual Code and following the Write your first app tutorial. This issue was resolved by just closing and reopening the project.