I had this issue but only on one build variant, I made sure all my gradle
files were up-to date but that didn't fixed it.
To solve it I closed android studio
and navigated to the project file
click on the app folder and deleted the build folder.
Once deleted I reopened Android Studio and launched the android project,
I then clicked File -> Invalidate Caches / Restart -> Invalidate and Restart
.
This worked for me and can now run every build variant without any problems, I've not had the same issue since.