React-native: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Created on 24 May 2020  Â·  8Comments  Â·  Source: facebook/react-native

TypeScript\MyApp\android\' is not recognized as an internal or external command
Could not find or load main class org.gradle.wrapper.GradleWrapperMain

C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp>yarn android
yarn run v1.22.4
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
'TypeScript\MyApp\android\' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
'TypeScript\MyApp\android\' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

    at makeError (C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp\node_modules\execa\index.js:174:9)
    at C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
    at async Command.handleAction (C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp\node_modules\@react-native-community\cli\build\index.js:186:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

React Native version:

C:\Dev\Projects\NodeJsStack\React-Mobile\React&TypeScript\MyApp>npx react-native info
info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz
    Memory: 9.90 GB / 19.88 GB
  Binaries:
    Node: 14.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-R | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: Version  3.4.0.0 AI-183.5429.30.34.5452501
  Languages:
    Java: 1.8.0_211 - C:\Program Files\Java\jdk1.8.0_211\bin\javac.EXE
    Python: 2.7.18 - C:\Python27\python.EXE
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. yarn android
  2. npx react-native run-android

Expected Results

Build and run react native android app

Needs

Most helpful comment

This solution worked for me.

  • Install gradle (https://gradle.org/install/)
  • in /android folder run gradle wrapper

System and libraries information

  • System:
    OS: Windows 10 10.0.19041
    CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
    Memory: 20.18 GB / 31.93 GB

    • Binaries:
      Node: 14.13.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
      Watchman: Not Found

    • SDKs:
      Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      Android NDK: Not Found
      Windows SDK: Not Found

    • IDEs:
      Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6821437
      Visual Studio: Not Found

    • Languages:
      Java: 1.8.0_242-release
      Python: 3.9.0

    • npmPackages:
      @react-native-community/cli: Not Found
      react: Not Found
      react-native: Not Found
      react-native-windows: Not Found

  • npmGlobalPackages:
    react-native: Not Found

All 8 comments

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
'TypeScript\MyApp\android\' is not recognized as an internal or external command,
operable program or batch file.

https://reactnative.dev/docs/environment-setup

I have found the solution...

This come out on my leptop... When I setup the env on pc it works. So I
realized that using choco no install NodeJs was the issue...

I deleted all global path related to Android Studio.
Uninstall nodejs, and python.

And reinstall all over again, with Nodejs 12 (setup from Oficial website)...
And it worked on my leptop also.

On Mon, May 25, 2020, 14:46 fabriziobertoglio1987 notifications@github.com
wrote:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
'TypeScript\MyApp\android\' is not recognized as an internal or external command,
operable program or batch file.

I think it is selfexplanatory otherwise you should give us a clear
explanation on why your android environment is not working

android env includes the sdk, gradle and many other dependencies that
needs to be globally availalbe in your terminal to run those commands

seems to me that you don't know how to set the dev environment but that is
not a good reason to open an issue on github .. issues are opened to fix
bugs

follow the instructions here

https://reactnative.dev/docs/environment-setup

but i suggest you to use expo

Your issue would only be acceptable after only demonstration that those
commands run in your terminal .. (./gradlew)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/28960#issuecomment-633555012,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AKG227TE6Q6SC2L4EYHCEGLRTJSB3ANCNFSM4NIX7WTA
.

I think this is because we should add distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.z in android\gradle\wrapper\gradle-wrapper.properties

I think this is because we should add distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.z in android\gradle\wrapper\gradle-wrapper.properties

nope its not working

same issue

Same issue here..

This solution worked for me.

  • Install gradle (https://gradle.org/install/)
  • in /android folder run gradle wrapper

System and libraries information

  • System:
    OS: Windows 10 10.0.19041
    CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
    Memory: 20.18 GB / 31.93 GB

    • Binaries:
      Node: 14.13.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
      Watchman: Not Found

    • SDKs:
      Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      Android NDK: Not Found
      Windows SDK: Not Found

    • IDEs:
      Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6821437
      Visual Studio: Not Found

    • Languages:
      Java: 1.8.0_242-release
      Python: 3.9.0

    • npmPackages:
      @react-native-community/cli: Not Found
      react: Not Found
      react-native: Not Found
      react-native-windows: Not Found

  • npmGlobalPackages:
    react-native: Not Found

Try building in another folder. Remove any special characters from the folder url, like - and &. That worked for me

Was this page helpful?
0 / 5 - 0 ratings