How to resolve when Gradle is not recognized as an internal or external command?
If you encounter the error “gradle is not recognized as an internal or external command” while running a Gradle command, you can try the following solutions:
- Ensure that you have installed Gradle correctly. You can verify the installation by running the command “gradle -v” in your terminal. If you haven’t installed Gradle yet, please follow the guidelines on the official Gradle website for installation.
- Add the installation path of Gradle to the system’s environment variables. On a Windows system, you can do this by following these steps:
- Open the Control Panel and select “System and Security”.
- Click on “System” and then choose “Advanced System Settings”.
- Click on the “Environment Variables” button in the pop-up window.
- Locate the variable named “Path” in the “System Variables” section, and click on the “Edit” button.
- Add the installation path of Gradle to the end of the variable value, separating multiple paths with semicolons.
- Click “OK” to save the changes, then close all open dialog boxes.
- Restart the Command Prompt window. After installing Gradle or modifying environment variables, you need to restart the Command Prompt window for the changes to take effect.
- Check the version of Gradle. Sometimes, the Gradle version you installed may not be compatible with the project you are running. Specify a version number in the project’s build file (e.g. build.gradle) that is compatible with the Gradle version you have installed.
If the above solutions still don’t work, you can try uninstalling and reinstalling Gradle, or seek help on the official forum or community for Gradle.