在环境中设置路径后,Gradle未运行

时间:2016-09-12 15:18:14

标签: java gradle build build.gradle

我下载了Gradle 3.0版本并在环境变量中设置了路径。

  

" C:\ New_Project_Softwares \ gradle3.0"

并在上面设置如下路径:

  

" path =%GRADLE_HOME%\ bin"

。但是当我在命令提示符下运行时

  

" gradle -v"

,它说" ' gradle这个'不被视为内部或外部命令, 可操作程序或批处理文件。" 。这意味着路径设置不正确。你能帮我解决一下如何为Gradle设置路径吗?

4 个答案:

答案 0 :(得分:3)

试试这个

set GRADLE_HOME=C:\New_Project_Softwares\gradle3.0
set path= %GRADLE_HOME%\bin;%path%
gradle -v

要确保路径已设置,请在命令提示符下键入set并在路径变量中查看设置的gradle路径。

答案 1 :(得分:0)

这是解决方案:

'gradle'未被识别为内部或外部命令

尝试运行gradle命令时,我发现'gradle'不会被识别为内部或外部命令。安装Android Studio后,我花了一些时间才知道Gradle可执行文件路径。因此,想分享这样可能会对某人有所帮助......

gradle可执行文件通常安装在此处(由Android-Studio安装时):

**<user_home_dir>.gradle\wrapper\dists\gradle-<version>-bins\<somekey>\gradle- 
<version>\bin**

<user_home_dir>, refers to the user directory, eg. C:Users/myuser

<version>, refers to installed gradle version number like 4.4 or 4.4.1 etc

整条路径如下所示

C:\Users\Satish\.gradle\wrapper\dists\gradle-4.4- 
all\9br9xq1tocpiv8o6njlyu5op1\gradle-4.4\bin 

enter image description here     选择路径,然后点击修改按钮

enter image description here

您必须在环境变量PATH中设置此类路径。然后关闭并重新打开cmd提示符。现在您可以运行gradle命令

尝试,您可以看到以下详细信息 enter image description here

答案 2 :(得分:0)

如果您使用的是同一终端(CMD),请尝试重新启动可能有用的终端。 我花了一个小时。

答案 3 :(得分:0)

只需按照他们的 gradle 文档进行操作:

https://gradle.org/install/

Microsoft Windows users

Create a new directory C:\Gradle with File Explorer.

Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-6.8 to your newly created C:\Gradle folder.

Alternatively you can unpack the Gradle distribution ZIP into C:\Gradle using an archiver tool of your choice.
Step 3. Configure your system environment
Linux & MacOS users

Configure your PATH environment variable to include the bin directory of the unzipped distribution, e.g.:

 $ export PATH=$PATH:/opt/gradle/gradle-6.8/bin

Microsoft Windows users

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-6.8\bin. Click OK to save.
Step 4. Verify your installation

Open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:

$ gradle -v

------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------