Search code examples
gradlegradlew

gradlew is not found (No such file or directory)


I load a project from git and build it successfully on MacBook. When I type './gradlew assembleRelease' in terminal window, I get an error:

bash: ./gradlew: No such file or directory

So I check if gradlew is under the project dir, but I can not find it. But I can still run task from 'Gradle projects' window.

What's wrong?


Solution

  • gradlew script is so-called Gradle wrapper, a self-contained script which allows people to run Gradle tasks without gradle installed. However it doesn't have to exist to execute Gradle tasks, it's absolutely optional.

    You can generate Wrapper in your project by executing the task

    gradle wrapper
    

    Afterward, you can use ./gradlew script instead of gradle from PATH

    To specify a Gradle version use --gradle-version on the command-line. Just execute the command:

    gradle wrapper --gradle-version <your gradle version>
    

    Take a look here for more exhaustive and comprehensive explanation: https://docs.gradle.org/current/userguide/gradle_wrapper.html