question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find or load main class org.gradle.wrapper.GradleWrapperMain

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

35reactions
C4cocommented, Oct 21, 2020

This solution worked for me.


System and libraries information

  • System: OS: Windows 10 10.0.19041 CPU: (6) x64 Intel® Core™ 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

1reaction
husni1992commented, Jun 5, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find or load main class org.gradle.wrapper ...
Go to System Preferences -> Security and Privacy -> Privacy Tab -> Files and Folders -> Java , and check the "Documents folder"...
Read more >
Could not find or load main class org.gradle.wrapper ...
stderr: Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain. Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.
Read more >
Could not find or load main class org.gradle ... - TechSupper
This error will be thrown when we are trying to clean or build the Gradle project and gradlew build unable to find the...
Read more >
Fix: Error: could not find or load main class org.gradle.wrapper?
One of the leading reasons why you're running in this issue is that you've deleted or corrupted the Gradle wrapper. In earlier versions,...
Read more >
Error Could not find or load main class org.gradle.wrapper ...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain Caused by: java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found