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

北战南征 提交于 2021-01-27 04:19:40

问题


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

ps: Im using genymotion for my android emulator marshmallow 6.0


回答1:


Got it,

Add the file location to environment variable PATH

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




回答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
    



回答3:


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)



回答4:


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




回答5:


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.




回答6:


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.



来源:https://stackoverflow.com/questions/43166266/gradlew-bat-is-not-recognized-as-an-internal-or-external-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!