Setting the Gradle home to local Gradle distribution solved the issue in my case.
- Java version: 9+181
- Gradle version: 4.1
- Intellij version: 2017.2.2
if we set to use default Gradle wrapper, IntelliJ downloads an earlier version of Gradle. I think it is the reason for failure.