161

I use IntelliJ IDEA Ultimate 14 and Gradle 1.2. I manage the project from the console, but I need to debug some of the code from the IDE.

When I try to make the project, this error window appears. When I try to debug the project,

Error: Unable to make the module: idappcli, related Gradle configuration was not found. 
Please, re-import the Gradle project and try again.

is written in the message window. How can I add the regular output paths to the project?

pillravi
  • 4,035
  • 5
  • 19
  • 33
user1339
  • 1,611
  • 2
  • 11
  • 5

12 Answers12

258

Try by opening the gradle task view and then click the refresh button. For me it solved the problem.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
Pierpaolo Follia
  • 3,020
  • 1
  • 14
  • 11
  • When you import the gradle project there is an "auto-import" checkbox. – devl Nov 01 '15 at 16:06
  • 4
    You can show the view by clicking `View` -> `Tool Windows` -> `Gradle` in the main menu next to `File` and `Edit`. – Matthias Braun Feb 19 '16 at 13:28
  • Has no effect for me on 15.0.2. – cloudsurfin Feb 19 '16 at 19:11
  • I still use this trick on my IntelliJ 2016.2.1 and it works without problems. Be aware that you need to wait that all dependencies are updated before being able to "use" again the project – Pierpaolo Follia Aug 12 '16 at 16:02
  • 3
    After upgrading to IntelliJ 2016.3 I encountered this issue. – Paweł Szczur Dec 09 '16 at 10:51
  • @Trejkaz perhaps because it takes a helluva lot of time. – John Red Jan 04 '17 at 07:39
  • @JohnRed a working project which takes a little bit longer to open up, versus a project which is quick to open but doesn't actually work; I'll take the one which is slower to open up. – Hakanai Jan 05 '17 at 09:03
  • I am getting this problem on a Gradle project Import. This if or recent "`Community Build: IntelliJ IDEA 2017.1.2 Build #IC-171.4249.39, built on April 25, 2017`" -- Three **Kotlin** simple "HelloWorld" type projects give the same errors. Reloading re-importing, cleaning-out the cache hadn't fixed things. Command line `gradle build` works, they run. What is it? Here I was thinking JetBrains were right behind Kotlin????? – will Apr 30 '17 at 11:24
80

I also had a similar problem, Go to : View -> Tool Windows -> Gradle.
Then press in Refresh Icon

enter image description here

dsharew
  • 10,377
  • 6
  • 49
  • 75
21

This fixed the issue "Please, re-import the Gradle project and try again." for me (IntelliJ Ultimate 17.3.3):

(1) Detached Gradle project:

detach

(2) Closed the project and (3) re-opened it via File > Open recent. IntelliJ will promt to import the now unlinked Gradle project. (4) Imported it and selected "Use auto-import" in the dialog.

enter image description here

marc
  • 977
  • 9
  • 14
17

I had the same problem with my Intellij IDEA version 2016.2 (Mac)

The solution was: In Intellij, Click on "View" then "Tool Windows" then "Gradle" then click on enter image description here

Alexandre Santos
  • 8,170
  • 10
  • 42
  • 64
9

I had to make sure the Use auto-import and the Use default gradle wrapper (recommended) were both checked.

File > Other Settings > Default Settings > Build, Execution, Deployment > Build Tools > Gradle

Intellij Gradle Preferences

Ray Hunter
  • 15,137
  • 5
  • 53
  • 51
3

I faced the similar issue when i update my IntelliJ Idea.

To fix it i ran the below command in terminal and it fixed my problem.

gradle cleanIdea idea
3

For most people the refresh of Gradle that has already been suggested might solve the issue.

For the others I figured out, that deleting the .idea direcotory and reimporting the project might help.

It can be that your resources directory is not added to classpath when creating a project via Spring Initializr. So your application is never loading the application.properties file that you have configured.

To make a quick test if this is the case, add the following to your application.properties file:

server.port=8081

Now when running your application you should see in the spring boot console output something like this:

INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): **8081** (http) with context path ''

If your port is still default 8080 and not changed to 8081, your application.properties files is obviously not loading.

You can also check if your application runs with gradle bootRun from command line. Which most likely will be work.

Solution:

  1. Close IntelliJ, then inside your project folder delete the ".idea" folder
  2. Reimport your project to IntelliJ like following: "Import Project" -> "select ONLY your build.gradle file to import". (IntelliJ will automatically grab the rest)
  3. build and run your application again

See official answer by IntelliJ Support: IDEA-221673

Flavio Caduff
  • 901
  • 1
  • 10
  • 16
2

This works for me:

  1. Close the IntelliJ Idea
  2. Delete 'gradle' and '.gradle' folders from the project root
  3. Start IntelliJ Idea and import the project as gradle

screensshots before and after

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
stkotok
  • 101
  • 1
  • 5
1

In my case the root cause was a missing proxy configuration. Once I configured it properly I was able to Refresh gradle projects and it finally downloaded missing files and set up the project correctly.

File > Settings > Appearance & Behaviour > System Settings > HTTP proxy

then

View > Tool Windows > Gradle 

and Synchronize button

Leos Literak
  • 8,805
  • 19
  • 81
  • 156
0

I went into the IntelliJ Gradle preferences:

Menu: Preferences > Build, Execution, Deployment > Build Tools > Gradle

And under Project Level Settings, switched the radio button to "Use default gradle wrapper (recommended)"

Hit the make button, and was in business!

sparkyspider
  • 13,195
  • 10
  • 89
  • 133
-1

@user1339 I also had the same problem. Please, read this question Building war with Gradle, Debugging with IntelliJ IDEA. It'll be very helpful for you. And recommendation for the 'Make' task. As message said, I should try to re-import the Gradle project and try again. In my case this advice became very helpful.

Community
  • 1
  • 1
Ray
  • 1,788
  • 7
  • 55
  • 92
-1

I recommend to try to 'Build > Rebuild Project'.screen capture of menu

Namo
  • 456
  • 5
  • 11