compile find a bad version of gradle

It's possible you might be building the project with gradle installed locally instead of using the wrapper i.e. using gradle build instead of ./gradlew build.


These are the steps I took to fix the same problem.

  1. I had a new project with a build.gradle file, but did not have a copy of gradle wrapper in my project directory. I think this caused the default gradle version for my IDE to be used (IntelliJ) and this is an older version.
  2. Gradle was already installed on my system.
  3. Ran "gradle wrapper" in my project directory.
  4. Edited ./gradle/wrapper/gradle-wrapper.properties and made sure "distributionUrl" was pointed at the gradle version I wanted (4.6 in my case).
  5. Reran my build and the correct version was then downloaded and installed. Problem fixed.

I hope this helps someone!

I copied my gradle wrapper folder over from another project, and edited ./gradle/wrapper/gradle-wrapper.properties