skip to Main Content

Beginner here.

I get this build error when trying to build a project in visual studio code:

Executing Gradle tasks as part of a build without a settings file is not supported. Make sure you are executing Gradle from a directory within your Gradle project. Your project should have a 'settings.gradle(.kts) file in the root directory.

The thing is, is that there is already one there.

I believe it is because it is VSCode is using Gradle 7.x.x when I should be using 6.5.0.

Does anyone know how to change gradle version on visual studio code?

2

Answers


  1. If you’re using the Gradle for Java extension in VSCode and you have the Gradle wrapper in your project, the extension should use the version the wrapper is using by default, so specify the correct version there.

    You can do that by manually updating the distributionUrl property in <your-project>/gradle/wrapper/gradle-wrapper.properties or by running the below command:

    ./gradlew wrapper --gradle-version <your-desired-version>
    

    If you don’t yet have a Gradle wrapper in your project, I would suggest you add it as it is the recommended way to execute Gradle builds. You can add it to your project with the following command

    gradle wrapper --gradle-version <your-desired-version>
    

    All listed commands are meant to be executed in the root folder of your project.

    Documentation on the wrapper: https://docs.gradle.org/current/userguide/gradle_wrapper.html

    Login or Signup to reply.
  2. I just managed to set the gradle version in VS code explicitly by performing the following steps:

    1. Open the user settings (press F1, type "Preferences: Open User Settings (JSON)"

    2. Add the following two settings to the file (settings.json):

      "java.import.gradle.wrapper.enabled": false,
      "java.import.gradle.version": "4.4.1"

    3. Reopen your gradle project

    Before doing this, VS code wanted to use gradle 7.3. It created the folder projectroot/.gradle/7.3, and failed to build my rather old project.

    After performing the above changes I noticed the folder projectroot/.gradle/4.4.1 appearing and my legacy project was able to build from inside VS code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search