'gradlew.bat' is not recognized as an internal or external command
Asked Answered
C

7

8

So i am trying to start a react native android project in windows 10 based on the Getting Start React Native. I am stuck at the last step->react-native run-android

Screenshot of command prompt

ps: Im using genymotion for my android emulator marshmallow 6.0

Catercorner answered 2/4, 2017 at 8:31 Comment(0)
C
5

Got it,

Add the file location to environment variable PATH

C:\Users\user\AppData\Local\Android\Sdk\tools\templates\gradle\wrapper

Catercorner answered 8/4, 2017 at 10:16 Comment(2)
I do not have templates/ directory in my tools/ directory. I have tried the other solution (of adding gradle installation path) but have no success. I am missing gradlew.batSpoonerism
However the gradle -v command works well, as I have added Gradle installation path to environment variable. I'm using Win 10.Spoonerism
D
2

Another version of the @Kai Jie findings, that works for me.

Compiling previous answers I did the following to get Android SDK and gradle working (You need gradle working anyway to compile your Android project):

  1. Prerequisites. You have gradle installed in the folders like I found on my computer. Please, check it:

    C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
    
  2. Set a new system variable (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables). Do not forget to change a gradle version.

    GRADLE_HOME   C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
    
  3. Add the following path to system paths (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables):

    %GRADLE_HOME%\bin
    
  4. You might want to REBOOT your computer, to make sure, that the system sees the variables.

  5. Check if gradle works properly with the terminal commands

    $ gradle -v
    
Dispensable answered 4/3, 2018 at 5:44 Comment(1)
I do not have templates/ directory in my tools/ directory. I have tried the other solution (of adding gradle installation path) but have no success. I am missing gradlew.bat. The gradle -v command works though.Spoonerism
H
1

If the environment variables are set. I found that you need to actually start gradle. Then you can use the gradlew command.

If you are learning from Spring.io. Their site says to just run

./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar

That will fail unless you first run

gradle

Intellij had me in the correct directory so I just deleted

./

and run

gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar

The app started right up.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)
Habit answered 9/8, 2019 at 14:56 Comment(0)
W
1

if your gradlew.bat file is being generated but delete itself after a few second than it's a problem of your android studio . steps to follow : 1 . open your android studio and click on configure. 2. Go to setting there. 3.Click on Build,Execution,Deployment => Build Tools => Gradle. 4. check Gradle user home if it's pointing to .gradle file location or not .If it's not than give the correct path of .gradle file like this in my case C:/Users/Your_PC_Name/.gradle . 5. And than create new reactproject.

Winfordwinfred answered 28/11, 2020 at 15:18 Comment(1)
Thank you , you saved meBuyse
U
1

You probably have to do something like:

./gradlew assembleDebug

Unwinking answered 28/1, 2021 at 16:57 Comment(0)
B
0

Add code below to the bottom of build.gradle file

task createWrapper(type: Wrapper) {
    gradleVersion = '4.9'
};

then run gradle createWrapper in terminal

This will generate gradlew.bat file and corrospondinf gradlew files

Bustup answered 21/7, 2018 at 9:8 Comment(0)
B
0

in my case, I had a & sign in the name of the folder that I had put in the flutter project. removing it solved the problem for me.

Bigler answered 9/12, 2019 at 22:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.