This issue has been annoying me for a while now. It’s present in many of my projects, in various 3.1.x versions of Android Studio. Solutions can be found in this thread and the ones that best worked for me are in this comment:
Copying and Pasting:
I’m having this error so often, and I find myself coming to this page again and again. Let me just collect the different answers that worked for me.
[Solution 1] Combines the ones that @TheAnonymous010 and @Farwa proposed
1.- File > Sync project with Gradle Files
2.- Build > Clean Project, Build > Rebuild Project
[Solution 2] Recreating Gradle folder
1.- File > Close Project
2.- You will see a small Android Studio window with a list of projects on the left, click on the “X” mark next to your current project (the one you’re working on)
3.- Now choose “Open an existing Android Studio Project” and re-open it from zero. After the “Indexing…” phase, you’ll probably get your app module back to work