huyn
huyn

Reputation: 551

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?

Upvotes: 53

Views: 178080

Answers (9)

KAUSHIK PARMAR
KAUSHIK PARMAR

Reputation: 623

  1. Check the android directory if there gradlew exist or not.

  2. If gradlew does not exist then execute following command.

  3. On CommandLine tool, change directory to android

    $ cd android

    $ gradle wrapper --gradle-version 6.0.1 (you can keep your desired version)

This will generate everything related to gradle with default config.

Upvotes: 3

Daniel Opiyo
Daniel Opiyo

Reputation: 317

Faced the same challenge a while back and didn't want to update my access rights to any file.

SOLUTION:

I navigated to the android folder within my project and run the commands from there and it worked.

Upvotes: 0

Navin Kumar
Navin Kumar

Reputation: 4027

Delete the gradlew file inside android folder, then run

- flutter clean
- flutter pub get

Upvotes: 0

yoAlex5
yoAlex5

Reputation: 34391

bash: ./gradlew: No such file or directory

Add the execute permission for all users to the existing permissions

chmod +x gradlew

[gradle vs gradlew]

Upvotes: 16

Mostafa Wael
Mostafa Wael

Reputation: 3846

You should add the execute permissions. Either use chmod 777 gradlew or chmod +x gradlew.

Upvotes: 1

Shah
Shah

Reputation: 505

In my case I have moved the project from a Windows machine to Mac and it contains carriage returns '\r'.

brew install dos2unix

find . -type f -exec dos2unix {} \;

./gradlew clean build

Upvotes: 3

Asim Gasimzade
Asim Gasimzade

Reputation: 105

For me it was missing name for data binding variable in one of the XML files.

Upvotes: 0

Sergei Voitovich
Sergei Voitovich

Reputation: 2962

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

Upvotes: 103

Ranvir
Ranvir

Reputation: 2152

In my case I copied gradlew file from windows(10) to linux(centos7).

So had to run

[user@server]$ dos2unix gradlew

And it worked.

Update:

If you have copied from windows as in my case. Do one thing, open it in notepad++, Go to View -> Show Symbol -> Show End of Line. You can notice CRLF This is the Windows EOL. Now convert it so you don't have to redo it. To convert notepad++ -> Edit -> EOL Conversion -> Unix (LF)

That's it, while pushing to git fiddle aroung .gitattributes

Upvotes: 21

Related Questions