Copyright Notice:

This account published articles are from the public account, Chengxiang Moying (cxmyDev), chengxiang Moying all rights reserved.

Shall not be reproduced without permission.

One, foreword

Gradle is recommended for Android projects and needs to be supported by different versions of Gradle. As a result, if you are maintaining multiple projects at the same time, installing only one Gradle version is not sufficient unless you keep multiple projects upgraded simultaneously.

You can use the SDKMAN to manage multiple versions of Gradle. Gradle’s documentation recommends that you use the SDKMAN to manage multiple versions of Gradle.

SDKMAN is a tool for managing parallel versions of multiple SDKS on Unix-like systems. If you want to use it under Windows, you need to use Cygwin, PowerShwll, etc., or directly use the official recommended Scoop to manage the SDK.

The following is a brief introduction to using SDKMAN to manage multiple Gradle versions on Mac OSX. Of course, SDKMAN is not only used to manage Gradle, but also to use Gradle as an example.

Second, the SDKman

1. What is SDKMAN

SDKMAN stands for The Software Development Kit Manager, and as The name suggests, it is a tool for managing SDKS. It provides a convenient command-line interface (CLI) and API for installing, switching, deleting, listing candidate SDK versions, specifying SDK versions, and so on.

You can use curl to download the url and add it to the environment variable. You can use curl to download the url and add it to the environment variable. Install common official documents directly.

SDKMAN installation document address: sdkman. IO /install.htm…

After the installation is complete, run the SDK version command to check whether the current installation is complete and the installed version.


2. How to use SDKMAN

1. Check the help documentation

It’s never wrong to start something new by checking the help documentation.

In SDKMAN, the SDK help command is provided to view the help documentation.

As you can see from the help documentation, SDKMAN commands are very simple, with only necessary commands.

2. Install the specified Gradle version

With the SDKMAN installed, we can manage our Gradle using the SDKMAN. If you need to install a new Gradle version, you can use the install command to install it. Of course, for SDK management purposes, the installation needs to specify the version number.

Command: SDK install gradle 3.4

For example, if you want to install Gradle version 3.4, you can see the following figure.

After the download is complete, it will ask if the downloaded version is used as a default version. If specified, the current default version is the downloaded version, in this case 3.4.

3. Check the current Gradle version

If you already have Gradle installed using the SDKMAN, you want to see Gradle installed.

Command: SDK list gradle



sdk list
*
>

4. Remove the installed Gradle

When the installed SDK version is no longer in use, you can choose to uninstall it. Of course, you need to specify the version number to uninstall the SDK.

Command: SDK uninstall gradle 3.4

/sman-uninstall.png

5. Set the default Gradle version

When installing a new Gradle SDK version, you need to choose whether to set it to the default version. If you select Y, the latest downloaded SDK version will be used by default. After the single configuration is complete, you can run the SDK default command to modify it.

Command: SDK default gradle 3.3

6. Use a temporary Gradle version

Sometimes, we don’t need to set up a permanent SDK version, just for temporary use, using the command SDK use to specify a temporary SDK version. The provisionally specified SDK version is used only in the current shell window.

Command: SDK use gradle 3.4

7. Check the Gradle version you are using

To view the current Gradle version, run the SDK list Gradle command as well as the SDK current command.

Command: SDK current gradle

3. Modify the CONFIGURATION of the AS

After specifying the Gradle version to use with the SDKMAN, if you find that you are still using an older version of Gradle in Android Studio, you need to check whether you are specifying the Gradle version to use in Android Studio.

Go to the Preferences window and find the Gradle option.

You need to specify “Use default gradle Wrapper “. If this fails, try restarting Android Studio.

Three, endnotes

It’s really convenient to use SDKMAN to manage various SDK versions, and these commands have abbreviations. For more details, check the official documentation.

SDKMAN official address: sdkman. IO /

Think it’s good. Just give it a thumbs up before you leave.

Qr code. JPG