17

Getting error - 'gradlew' is not recognized as an internal or external command. operable program or batch file. inside Android Studio terminal.

Can anyone please tell why it's not recognizing gradlew

live-love
  • 48,840
  • 22
  • 240
  • 204
Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111

13 Answers13

39
  1. gradlew command is available in your project directory. If you are trying to run this command from somewhere else it will throw error.
  2. Also gradlew command package is automatically generated by Android studio when you create a new project. It will also prompt you to generate new gradle wrapper when you open the project.
  3. you have to use ./gradlew instead of gradlew , if you are using Mac or Linux
Boken
  • 4,825
  • 10
  • 32
  • 42
Vivek Vashistha
  • 832
  • 9
  • 17
17

It's under the Android folder, so you have to do cd Android first from your project root folder, then :

PS C:\code\my_app\android> ./gradlew signingReport
live-love
  • 48,840
  • 22
  • 240
  • 204
10

in vscode do this step

  1. go to your project directory
  2. cd to android
  3. type ./gradlew in your terminal instead of gradlew
  4. voila, it works for windows user
Boken
  • 4,825
  • 10
  • 32
  • 42
cxkeeley
  • 209
  • 3
  • 3
5

Assume that you app's name is video_compresser, so when you open terminal on Windows PC(because I am trying this on Windows) it shows the prompt like this.

C:\Users\Nuwan\StudioProjects\video_compresser>

If you run gradlew from here you will get the below message

'gradlew' is not recognized as an internal or external command,
operable program or batch file.

so you have to go to android directory by typing cd android command from terminal.

then the prompt should be like this,

C:\Users\Nuwan\StudioProjects\video_compresser\android>

then type gradlew followed by other commands you need and the error should be gone.

Nuwan Thisara
  • 226
  • 5
  • 15
4

Try using, ./gradle clean ./gradle assembleRelease worked for me.

3

make sure you have debug.keystore file in
PS C:\code\my_app\android> before you run ./gradlew signingReport

Sahil bakoru
  • 393
  • 1
  • 4
  • 10
1

Instead of the powershell, use the Windows Command Prompt to run the command.

(This is an accidental finding. I used the visual studio code terminal to run the command gradlew assembleRelease to build the apk of a react-native project, but it outputs an error similar to above. I tried bash terminal, again failed to run. Out of curiosity, I used the Windows command prompt, then it worked. Hope this will help if other solutions are not working).

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
1

If you use powershell, and the gradlew file is in the terminal current work directory, try .\gradlew instead of gradlew. Powershell don't run the command in the current work directory automatically.

Kicey
  • 43
  • 3
0
ionic cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle

cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- --packageType=bundle
Ashish
  • 2,026
  • 17
  • 19
0

go to android directory by typing "cd android" in terminal.

then the prompt should be like this, PS C:\src\offx> cd android PS C:\src\offx\android>

(//then type) ".\gradlew signinReport" PS C:\src\offx\android> .\gradlew signinReport

Then you will get your sha keys

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 17 '22 at 13:19
0

gradlew command is only available in your project directory or gradlew file location. If you are trying to run this command from somewhere else it will throw error. so go to that particular location where gradlew file available

0

Try running

./gradlew signingreport

I didn't have JDK installed so, you have to do that as well if you see something like: "No JDK set and/or no java in path to be found". After installing JDK just close and open again Android Studio and do

./gradlew signingreport

once more. You should be fine by now.

-2

I am using windows OS and have to run a Java project in IntelliJ. I used the command prompt in admin mode then it worked for me.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31453285) – pheeleeppoo Apr 07 '22 at 08:31