Resolving Gradle issues in IntelliJ IDEA


Working with a Gradle Project in IntelliJ can sometimes be a bit frustrating. Once you make any dependency/plugin changes in your project, you might bump into multiple errors while trying to build your project. I faced a similar issue yesterday and in this blog, I will be explaining how to resolve Gradle sync related issues while working in IntelliJ.

Gradle is an advanced general purpose build management system based on Groovy.

gradle

When you make any dependency changes in your gradle build file, you might receive errors while building your project from within the IDE – as a result of IntelliJ not resolving the dependency changes.

To resolve this issue, navigate to the Gradle Tool window via View -> Tool Windows -> Gradle

Gradle Window in IntelliJ

Click the highlighted button to refresh all registered Gradle projects after changes have been made to the Gradle file. Refresh all Gradle projects‘ will create/restore project structure for all gradle modules in the IntelliJ project —

Refresh all Gradle Projects

You should be able to verify the list of dependencies, so that there are no Gradle sync issues —

Gradle Dependencies

Opening an existing Gradle Project in IntelliJ

If you want to open a Gradle project, it is a good idea to select the ‘build.gradle’ file in the wizard  —

IntelliJ IDEA Open Project

Gradle Build File

Now select the option to ‘Open as Project’ —

Open as Project

Make sure to use the auto-import option and also point to the appropriate JDK version —

Import Gradle Project

That is it. You should now be able to open/import the Gradle project in IntelliJ and build/run it —

IntelliJ Project

Conclusion

Make sure to Refresh your Gradle projects when you modify any dependencies or plugins. This will resolve any sync issues and restore project structures in the IntelliJ IDE.

For more detailed information, check the Gradle documentation in the Jetbrains website —

https://www.jetbrains.com/help/idea/gradle.html



Categories: IntelliJ, Java

1 reply

  1. worked, thank you

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: