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



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

error Could not install the app on the device, read the error above for details. 
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: /gradlew app:installDebug.

If you are getting the above error while working on your Android Project in Android Studio, well this can be solved by following the below steps.


Step 1:

The first thing you should do is make sure that gradlew (or gradle.bat) file is present in your project root folder.

If you see these files are missing then you will need to add the Gradle Wrapper

Run the below command as per your Operating System:

Linux, macOS: ./gradlew wrapper

Windows: gradlew wrapper

Read More: https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:adding_wrapper


Step 2:

Now check the Gradle version just to be sure it has been installed correctly.

gradle --version

Step 3:

Another thing that you can do is check if ANDROID_HOME environment variable is set correctly.

Windows: echo %ANDROID_HOME%
macOS/Linux: echo $ANDROID_HOME

Step 4

Try to re-build your project.

Windows: gradlew clean
macOS/Linux: ./gradlew clean

This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap