简体   繁体   English

如何更改 Gradle 版本?

[英]How to change the Gradle version?

I would like to change the Gradle version to 3.5.1 according to the project version received from git using this eclipse.我想根据使用此 eclipse 从 git 收到的项目版本将 Gradle 版本更改为 3.5.1。

So I changed the editing path for the system environment variable, but if you enter 'gradle -v' in cmd, only 4.4 appears.所以我改了系统环境变量的编辑路径,但是如果在cmd中输入'gradle -v',就只出现4.4。

I looked for various solutions on the Internet, but it didn't work out.我在互联网上寻找了各种解决方案,但都没有成功。

How can I change the version?如何更改版本?

And how can I erase the existing version 4.4 completely?我怎样才能完全删除现有的 4.4 版本? I tried to erase it, but it kept popping up even if I deleted all the related files.我试图删除它,但即使我删除了所有相关文件,它仍然会弹出。

gradle -v : gradle -v

图片

One of the easiest way to change the gradle version is using sdkman .更改 gradle 版本的最简单方法之一是使用sdkman Install the required version you want and change whenever you want.安装所需的版本并随时更改。 Then hit然后打

  • sdk install gradle <versionId>
  • sdk use gradle <versionId>

To check the list of versions installed检查已安装版本的列表

  • sdk list gradle

First, you need to know where Gradle is installed on your device.首先,您需要知道 Gradle 安装在您的设备上的什么位置。 You can type where gradle in your terminal and the path will pop up.您可以在终端中输入where gradle的位置,路径将弹出。

Then, after you deleted the old version, go to the download page to download version 3.5.1.然后,删除旧版本后,go 到下载页面下载3.5.1版本。 After download, follow the instructions in Installing manually in the Gradle installation guide .下载后,按照Gradle 安装指南中的手动安装说明进行操作。

Make sure that the old version is not included in your environment variables.确保旧版本不包含在您的环境变量中。 If so, remove the old version and add the new one.如果是这样,请删除旧版本并添加新版本。

You can check Windows path variable by typing echo %PATH% in CMD.您可以通过在 CMD 中键入echo %PATH%来检查 Windows 路径变量。

Using Gradle Wrapper使用 Gradle 封装

To quote the manual :引用手册

If your existing Gradle-based build uses the Gradle Wrapper, you can easily upgrade by running the wrapper task, specifying the desired Gradle version:如果您现有的基于 Gradle 的构建使用 Gradle Wrapper,您可以通过运行 wrapper 任务轻松升级,指定所需的 Gradle 版本:

./gradlew wrapper --gradle-version=7.4.2 --distribution-type=bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM