'Error with Gradle using VS Code: "Could not run build action using Gradle distribution"

I've started getting the following error message when opening an existing Gradle project in VS Code after upgrading the Gradle installation on my computer:

Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.5.1-bin.zip').

I've found similar questions floating around with different version numbers, such as: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.9-bin.zip'.



Solution 1:[1]

I assume the error was being caused as the Gradle configuration in the project directory became outdated. I managed to make VS Code to work again after reinitialising the Gradle config in the project directory as follows:

1, Take a backup of both build.gradle and settings.gradle
2. delete both of them
3. run the command gradle init
4. Restore both files

EDIT:
Updated as per the useful comment from @ankitj

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1