I have a gradle 6.0 project with Spring 2.1.7.
When I try to refresh all gradle projects
from intellij
I got an error:
Unable to load class 'org.gradle.api.internal.plugins.DefaultConvention'. Possible causes for this unexpected error include:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
- The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
- Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
I use intellij v 2018.3.4 and I've configured it to use the gradle wrapper:
The gradle-wrapper.properties looks like this:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
If I run the gradle wrapper from command line there are not problems. Also If I trigger a gradle task (build, clean ...) from Intellij I have no errors.
I have another wired issue that could be related to this one. In my build.gradle I use spring boot 2.1.7 and If I run my jar from the command line I can see from the Spring Boot banner the configured version 2.1.7.
Instead If I run the application form Intellij I see that It is using Spring Boot 2.0.8, also if I expand the External libraries tree I see:
the build.gradle looks like:
buildscript {
ext {
springBootVersion = "2.1.7.RELEASE"
springBootDepManagementVersion = "1.0.8.RELEASE"
}
}
plugins {
id 'idea'
id 'java'
id "io.spring.dependency-management" version "${springBootDepManagementVersion}"
id 'org.springframework.boot' version "${springBootVersion}"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
....
}
Thank you
We can do this by: Selecting one of the suggestions in the message; Pressing on the Refresh Gradle icon in the top right, Using the keyboard shortcut ⇧⌘I (macOS), or Ctrl+Shift+O (Windows/Linux).
We can configure the settings for how IntelliJ IDEA syncs with Gradle by pressing the settings icon in the Gradle tool window, and selecting Auto-Reload Settings. We can set IntelliJ IDEA to automatically reload the project after "Any changes" in the build script files, so changes are automatically reloaded.
In some cases when your Gradle files are deleted or corrupted you will not be able to download new Gradle files in android studio. In this case, we have to delete the Gradle files which are present already and then again sync your project to download our Gradle files again.
I solved the problem downgrading the gradle wrapper to 5.6.4. Apparently my Intellij version does not support gradle 6.0.0
Downgrading also do the job for me:
gradlew wrapper --gradle-version 5.6.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With