"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
Please sign in to leave a comment.
Try File | Invalidate Caches?
Hi Dmitry,
Yes, that did it. You're the man! Thank you,
Alex
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
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.
Hi Dmitry,
Your solution worked for me. Thanks
@Dmitry it worked like charms. Thank you.
@Dmitry, you saved my ass @ 2020.1.29
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.
Hi @Dmitry ,
Your answer solved my problem. Thank you from 2020.
The other solution works for me:
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?
Hello Aaron,
Please attach idea.log ("Help | Show Log in...") after restarting IDE.
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.
Holger Segnitz it's by design, please check my answer at https://stackoverflow.com/a/61180376/104891 .
Thanks @Serge Baranov it was really helpful !
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!
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).
Thank you Dmitry
it works !!
Thank you Dmitry from 2021. Legend.
Thanks Dmitry