This did the trick for me:
- Close Android Studio
- Rename project root directory name
- Open Android Studio
- Open the project
- Clean project
If your settings.gradle contains the below line, either delete it or update it to the new name.
rootProject.name="Your project name"
Edit:
Working in all versions! Last test: Android Studio Chimpmunk Jun 2022.