Intellij IDEA cannot resolve any import statement 关注
I am struggling recently with very strange issue. Suddenly, my intellij IDEA stopped resolving all java import statements.
The only solution that worked so far for me was to uninstall intellij IDEA and install it again. Although, when I import one of my projects upon ~4 hours it cannot resolve any import statement again. This happes only for that one project. It is Eclipse RCP based.
Unfortunatelly, I cannot share with you the source codes of that project.
What I have already tried is the following:
- Remove .idea folder
- Remove all *.iml files
- Invalidate and restart
None of this works for me. When I create project from the scratch it also tells me that import statements cannot be resolved
My intellij IDEA version: 2019.1 Ultimate
It cannot event resolve base classes like String
My SDK is set up properly
Thank you for your help.
Please clarify if the project is built with Maven? Please check if the issue is reproduced with other JDK versions. Does the project compile or the compilation fails corresponding the unresolved errors in Editor? Please share idea.log (File -> Show Log in Finder). Thank you.
It happend twice when I imported Eclipse RCP project. Once it fails with Eclipse RCP project it affects whole intellij idea and it was not working anymore for maven based projects and any other project.
I had tried other JDK versions as well but it did not work.
The project could not have been compiled. When I clicked on red bulb it told me to set up JDK. A popup window appeared. I have picked JDK 1.8 but again JDK classes could not have been resolved.
Unfortunatelly, I cannot share log file with you anymore. I had to re-install intellij idea since I use it at work and it was the only known solution to me.
Once it happens again, I will share the log file with you.
Please share the idea.log in case the issue repeats. In case it happens please check if the project compiles with Maven (not with IDEA), if doesn't, please try deleting the JDK and adding it once again in Project Structure | SDKs.
Will do thank you
I cannot attach log files to this ticket. Could you please share your email with me so that I can send them via email?
Please create an issue at the YouTrack (https://youtrack.jetbrains.com/issues), data can be attached to it privately in case the visibility of issue is set to "visible to jetbrains-team". Please also provide the sample project the issue is reproduced with. Thank you!
Was this resolved, and then how? Have similar problem (on Ultimate 2019.1.3) that now starts to show up, tried the same steps, and get same problem.
It has not been solved yet. I cannot share source code of the project which produces the issue.
Maybe a simple eclipse rcp project will reproduce the issue. However, I have not checked it
NOTE: This comment is NOT BY THE ORIGINAL PROBLEM POSTER. To my knowledge, the problem is NOT RESOLVED.
As I commented that I had a similar problem: I actually got mine resolved: It seems like Intellij IDEA did not manage migrations of projects while upgrading.
I guess that in my case, the problem was that IDEA did not manage transition of Project Structure/JDK well after upgrade of IDEA
Hello Rickard, can you please clarify if your project is built with Maven/Gradle? Thank you
Hi Olga, my project was built with Gradle.
Rickard, can you please share the Gradle.build file or sample project where the issue is reproduced for you if possible. Thank you
FWIW, I was able to resolve the issue by refactor->rename the object and then renaming it back.
Gradle project, intellij 2019.3.1
This is absolutely a no go! Struggling about 4 hours to successfully build my project again without success!!! This happens after I upgraded to the new version. Downgraded to 2019.3.1 - nope - same error.
Can you please describe the error in more details. If possible and convenient, you may create an issue at the YouTrack, attaching idea.log file to it. Thank you
I upgraded my intellij ultimate to the latest version and I'm having the same problem. Anyone had found a solution?
Here is my idea.log.
I can build successfully, SDK set up, I just can't resolve the imports.
Have you tried to run "File | Invalidate Caches"? Is it reproducible with new sample project? Please try to temporarily disable "Kotlin" plugin.
Was this issue ever resolved? I am having the same problem and have tried all suggested solutions above with no luck.
Have you tried to run "Reimport" from Maven tool window?
Thanks for your response. I had tried 'Reimport' previously with no success.
I managed to resolve the issue, so I am posting my solution here so others may benefit from it in future.
On inspection of the logs, I noticed that there was a CSV plugin which was throwing an error:
I tried to navigate to the IDE Preferences, but realised that I was unable to open them (both through the menu and keyboard shortcut). Strangely enough, my "Quick Search" also was not working.
I managed to remove the plugin by navigating to ~/Library/Application Support/JetBrains/IdeaIC2020.1/plugins in my terminal and running rm -rf <plugin-name>. After restarting the IDE my imports resolved.
As a heads-up for others:
I had the very same problem and it was also caused by a plug-in. In my case it was SQLscout.
Upon uninstalling, everything is back to normal, but as soon as i reinstall it, I get the error again.
I have the same issue using IntelliJ EDU 2020.1 on Mac OS 10.11.6
I tried to find a plug-in in the idea log file but could not find one. Now I will try to reinstall IntelliJ or switch to Visual Studio Code, since this problem now keeps me busy for some hours already and does not seem to have been fixed within one year and nearly three months. This is disappointing.
when deleting my old version I found some hints, that IntelliJ tries to import settings from older versions when it launches the first time. So I found some older settings from a 2017 version which I deleted – hopefully this helps.
Probably some old plugins caused the wrong behaviour. In case you face the issue again, please feel free to create a bug report at the YouTrack (https://youtrack.jetbrains.com/) providing the idea.log file. Thank you
You can try not to ignore the *.class file in intellij setting.
Go to Setting, and search for File Type and click it. Delete *.class if it existed in the bottom line
I recently experienced this bug. I finally discovered the solution for my situation. I had recently started an new contract position and was in the process of on-boarding. I was setting up my desktop environment an encountered this bug while attempting to get the service that wa part of my first project to run locally. This was a large maven Java REST service project. I eventually discovered that IntelliJ does not read the maven settings.xml from the default config directory in your maven installation. Therefore it did not pick up the correct location of my local repository. I had to copy settings.xml to my $home/.m2/ folder, close the project, close IntelliJ, flush the .idea folder from the project root, restart Intellij and verify that the local repository was set correctly in the maven build settings. Only then could I import the project and have the dependencies all be satisfied. Hope this helps some other victim of this bug.
>I eventually discovered that IntelliJ does not read the maven settings.xml from the default config directory in your maven installation.
Sorry for the issue. IDE reads the settings.xml file specified in the Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | User settings file text box. If the settings file does not have the default (USER_HOME/.m2/ directory) location you can change it by overriding default value of this option.
Hi all, I usually use the community version of IDEA to create small projects, as I am just a high-school student. I wanted to try Intellij IDEA Ultimate for the first time. When I tried to import it, I too faced the same problem. Many base classes such as String and Scanner didn't get recognised automatically.
Hence, I checked the project structure settings as a first step, found that it was alright n automatically detected Java 8 OpenJDK. But still, no success. After hours of searching the web, I finally decided to check the JDK settings again. I don't know if this problem only occurs on linux, but to my surprise, there were two JDKs of the same version (java 8) in the list of detected ones, though I clearly remember installing it only once. On switching to the second one, it indexed the path and the issue solved. Hope this helps anyone here. Wish the JetBrains Team solves this ASAP.
Please tell what version of IntelliJ IDEA do you use? Is the issue reproduced with v2020.2: https://www.jetbrains.com/idea/download?
Was the JDK installed with the IntelliJ IDEA or you just defined the path to it? Thanks
I have the same issue with 2020.2. However it seems it's project-dependent. In my main work project I do not have any problem with resolving Java classes.
However I wanted to write some simple program, so I have copied old simple project so I don't need to setup everything from scratch. When I've opened it (deleted .idea & .iml) as Maven project, it was not able to resolve any JDK classes.
A bit strange thing for me from build log is that it uses CP from old Idea version (2019.3.3)
And here is content of idea.log:
As there is an error related to builder plugin, I have uninstalled it. Unfortunately it was not cause of this problem and it persists.
In my project Idea cannot resolve java imports
works just fine.
Could I provide you some other information to track this issue?
ok, in my case it seems it's related to Java Modules. Idea is not able recognize/suggest Java modules in version 14. When it comes to external libraries, it suggest them correctly.
Classes from java.base module are recognized/suggested correctly.
When I switch my project to Java 11/13 it works fine. However with Java 14 it does not.