"Cannot resolve symbol …" for all the Java classes

Answered

I just switched to the LEDA EAP (122.264), with a project having a mix of Java and Scala code. The project compile fine, but:

  • In the editor, in both Java and Scala file, any reference to a Java class which is part of the project is highlighted in red with the error "Cannot resolve symbol …".
  • References to classes in libraries are OK
  • References to Scala classes in the project are OK.


How is that possible, and what can I do to solve this?

Alex

0
20 comments

Try File | Invalidate Caches?

38

Hi Dmitry,

Yes, that did it. You're the man! Thank you,

Alex

1
Avatar
Permanently deleted user

I also have the same issue where my web module is not able to refer to my service modules. The project is building fine with mvn clean install, server starts but somehow I see the error - 'cannot resolve symbol' 

I tried other options such as Invalidated Caches/restart and deleted Caches files from a directory but no luck

IDE version installed - 2017.3 Ultimate

1

Please try to delete .idea directory and reimport the project from Maven. In case the issue persists, report at https://intellij-support.jetbrains.com/hc/requests/new and attach a sample project to reproduce it.

3

Hi Dmitry,

 

Your solution worked for me. Thanks

0

@Dmitry it worked like charms. Thank you.

0

@Dmitry, you saved my ass @ 2020.1.29

0

Some time it may be an issue where in you have disabled Enable-Auto Import on IntelliJ.

In this case please update project build file (pom or build.gradle) file and then do manual import changes.

This will reflect changes in the dependencies and should solve the problem.

0

Hi @Dmitry ,

Your answer solved my problem. Thank you from 2020.

0

The other solution works for me:

  1. close project
  2. rm *.iml
  3. rm -rf .idea
  4. from IntelliJ, New -> Project from Existing Sources, choose pom.xml under the project
2

Deleting .idea, .gradle and .build, I've tried invalidate caches, I've tried deleting the entire clone of the repository and starting over.  None of these seem to work.  Occasionally one seems to work for a little while but then the problem returns.  Is someone aware of an open issue that this is getting worked on?

0

Hello Aaron,

Please attach idea.log ("Help | Show Log in...") after restarting IDE.

0

I had this problem too, but it turned out, I just had to install OpenJDK (in my case the Corretto release) and point the IDE to it.

Project Structure > Project Settings > Project > Project SDK

Didn't work with the built-in JDK for some reason.

6

Thanks @Serge Baranov it was really helpful !

0

Serge Baranov I was wondering if you could help me. I am currently having a "Cannot resolve symbol …" issue after recently creating a .jar file using maven, since creating the .jar the functionality of inteliJ and the JDK no longer works. I have tried everything suggested in your answer to the stackoverflow thread, however I am unable to create any java code on my computer while this issue is present. I have uninstalled/reinstalled my java JDK, invalidated and restarted caches, checked the classpath and SDK tab's and still I cannot remove the "Cannot resolve symbol …" issue. Is there anything else I can try to resolve this issue? I have limited knowledge on maven so I do not know what has caused this issue. Many thanks!

1

Please contact support at https://intellij-support.jetbrains.com/hc/requests/new with the screenshots of the issue and the logs attached (Help | Collect Logs and Diagnostic Data).

0

Thank you Dmitry
it works !!

0

Thank you Dmitry from 2021. Legend.

1

Please sign in to leave a comment.