36

In an attempt to compile external jars, I have to use the terminal and do a clean. However, when I go into the root directory of my project and execute

gradlew clean

I get the following message:

-bash: gradlew: command not found

Here's a screenshot of my application folder's home directory.

Let me know if you need anything else, I'm not sure why this is happening.

Kgrover
  • 2,106
  • 2
  • 36
  • 54
  • Call `gradle clean` instead of `gradlew clean`. Did you install gradle? – pepuch Jun 10 '13 at 15:57
  • 2
    Maybe that's it- I thought it came with Android-studio. Was I mistaken? Doesn't android studio use gradle to compile in the first place? gradle clean doesn't help. – Kgrover Jun 10 '13 at 15:58
  • What console shows when after you call `gradle clean`? – pepuch Jun 10 '13 at 16:04
  • Same thing - command not found – Kgrover Jun 10 '13 at 16:05
  • 1
    Ok. I think that android studio installs gradle but doesn't add it to system PATH. If you want to build applications using command line instenad of IDE just find where android studio installed gradle and add it's path to PATH environment. – pepuch Jun 10 '13 at 16:07
  • 7
    You need to run it as ./gradlew clean – Siva Velusamy Jun 11 '13 at 14:57

3 Answers3

100

gradlew is not in your global path. To execute the 'clean' task (or any task for that matter) using the gradle wrapper (gradlew) in your project directory in your terminal, specify the current directory with the './':

./gradlew clean
Onyx
  • 3,769
  • 2
  • 22
  • 11
  • 30
    Running mac, you also have to do "chmod 755 gradlew" on the file before to make it executable. – Simon Bengtsson Mar 31 '14 at 16:06
  • 8
    Going with @SimonBengtsson, if you are using linux you must do "sudo chmod +x gradlew" before you do the "./gradlew clean" to make sure it is executable. It did not work until I did this. – Dick Lucas Apr 02 '14 at 21:57
  • gradlew will be executable file if you create it with 'gradle wrapper' command – smilyface Sep 15 '15 at 04:37
0

You need to give it the permission by running this one first:

chmod 777 gradlew
Long Dao
  • 1,341
  • 4
  • 15
  • 33
  • This worked. I guess this step is needed because gradle is installed by Android studio and not by user. So running this make gradlew clean or any gradlew command work. Don't know why this was down voted. – sofs1 Dec 11 '16 at 12:09
  • This also creates a security vulnerability as a bonus. :) Never follow Stack Overflow advice without thorough understanding. – Rudolf Adamkovič Nov 17 '22 at 14:45
0

gradlew is not in your global path. To execute the 'rebuild' task (or any task for that matter) using the gradle wrapper (gradlew) in your project directory in your terminal, specify the current directory with the './':

./gradlew rebuild