For Windows the solution is. To go manually into:
File -> Settings -> Build, Execution, Deployment -> Gradle -> check the “Create directories for empty content roots automatically”.
For Mac the solution is. To go manually into:
Intellij IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> check the “Create directories for empty content roots automatically”.