Intellij IDEA cannot resolve any import statement

Answered

Hi there,

 

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:

  1. Remove .idea folder
  2. Remove all *.iml files
  3. 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.

 

Maks

1
61 comments

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

  1. Closed the project
  2. Deleted directories: build, out, .idea
  3. Re-imported project
  4. Invalidated Cache and Restart
  5. Rebuilt project
  6. (still nothing worked)
  7. Then I went to Project Structure, added a new JDK configuration, but with the same JDK as before (in my case 1.8.0_211)
  8. repeated step 4-5

I guess that in my case, the problem was that IDEA did not manage transition of Project Structure/JDK well after upgrade of IDEA

2

FWIW, I was able to resolve the issue by refactor->rename the object and then renaming it back.

Gradle project, intellij 2019.3.1

2

In my case File -> Invalidate Caches/Restart... alone helped without deleting .idea folder and *.iml file  jazz.

2

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.

https://drive.google.com/file/d/1X7WymKf1Hduy-3tUqfo1SMDOExi2oair/view?usp=sharing

I can build successfully, SDK set up, I just can't resolve the imports.

1

Hello,

Have you tried to run "File | Invalidate Caches"? Is it reproducible with new sample project? Please try to temporarily disable "Kotlin" plugin.

1

>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.

1

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.

 

1

Just to add my 5 cents to the discussion. None of the suggestions seemed to fix my issue. I've tried reinstalling the IDE, changing the version and nothing helped. In the end, I found out that somehow my JDK got uninstalled from my PC (it was separately installed, not as part of IntelliJ), which was the cause for the IDE not locating classes from the Java core libraries. I'd suggest in addition to the other solutions, to make sure there is a valid JDK on the machine and the IDE is pointing to it.

 

1

Its unfortunate that it still happens in 2022.

1

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.

0
Avatar
Permanently deleted user

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.

0

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.

0
Avatar
Permanently deleted user

Will do thank you

0
Avatar
Permanently deleted user

Hi,

 

I cannot attach log files to this ticket. Could you please share your email with me so that I can send them via email?

 

Thank you

0

Hello,

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!

0

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.

0
Avatar
Permanently deleted user

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

0

Hello Rickard, can you please clarify if your project is built with Maven/Gradle? Thank you

0

Hi Olga, my project was built with Gradle.

0

Rickard, can you please share the Gradle.build file or sample project where the issue is reproduced for you if possible. Thank you 

0

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. 

0

Hello Info

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 

0

Hello, 

Was this issue ever resolved? I am having the same problem and have tried all suggested solutions above with no luck. 

Thanks, 

Elizabeth

0

Hello Elizabeth,

Have you tried to run "Reimport" from Maven tool window?

0

Hi Yaroslav, 

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: 

2020-05-14 12:35:13,849 [ 419847]  ERROR - aemon.impl.PassExecutorService - While loading class net.seesharpsoft.intellij.plugins.csv.intention.CsvShiftColumnLeftIntentionAction: net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnLeftIntentionAction has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 [Plugin: net.seesharpsoft.intellij.plugins.csv] [Plugin: net.seesharpsoft.intellij.plugins.csv]```

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.

0

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.


Best, Louis

0

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.

 

EDIT:

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.

0

Hello Kristian,

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

0

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

0

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.

0

Please sign in to leave a comment.