Java App - shows "Cannot resolve symbol" but App Compiles
Answered
I am working on a Java app with some example code I downloaded from Google and on many of the import statements and some variable definitions the UI shows the text in red with “Cannot resolve symbol” errors if I hover over the red text.
It was very frustrating because I thought my code was broken but I loaded it into another IDE and it didn't show the errors.
The app compiled and ran so I went back to IntelliJ
Is this some setting I need to change?
Thanks
Rich
Please sign in to leave a comment.
Hello Richard Morey
What you are seeing usually means that IntelliJ IDEA’s code analysis doesn’t have the same project configuration as the compiler, so the editor can’t resolve some classes or variables even though the project still compiles.
Please try the following checks:
pom.xmlorbuild.gradle, close the current project in IntelliJ IDEA, and re‑open it by selecting that file (not just the folder). This lets IntelliJ IDEA import the project model and dependencies correctly.src(or equivalent) folder is marked as Sources (blue folder). If the files are under a plain directory not marked as a source root, the editor won’t be able to resolve symbols properly.If the issue persists after these steps, please share:
Attach the zip file via our secure upload site https://uploads.jetbrains.com/, and share the uploadID. With that information, I'll see exactly how the project is configured and pinpoint why the editor can’t resolve the symbols while the code still compiles.
This worked, thanks!
Hi Richard Morey
Thanks for confirming it worked!
Have a great day!