I also have the same error.
I simply Invalidated caches and restart android studio and everything works fine then.
To Invalidated caches and restart Goto Files > Invalidate Caches/restart.
This is some sort of bug of the android studio it happens to me several times.