This error usually happens to me in Android Studio when I try to open a project that was moved from another path or location, also other circumstances might cause this, what works for me is:
- menu “Build”
- run “Rebuild Project”.
Then run app on device or emulator, and error goes away. I know the error has nothing to do with this but that’s what fixes it for me, try and let me know.