Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

"Cannot resolve symbol" in Intellij IDEA

Writer Mia Lopez

I'm fairly new to Intellij and Java and am unable to use libraries from one "module" in another. I am seeing red class names and getting "Cannot resolve symbol ..." errors all over the place:

enter image description here

The other modules are referenced in File | Project Structure all the other module's Paths are correct and include the *.classes I'm trying to use:

enter image description here

I have also tried a File | Invalidate Caches but am still having the same problems.

What do I need to do to fix this?

7 Answers

Listed below are steps which may fix the problem:

1.Invalidate and refresh the IntelliJ's caches

File Menu -> Invalidate Caches / Restart -> Invalidate and restart

2.Project SDK selection

Check project settings from File Menu -> Project Structure Ensure an SDK is selected for the Project SDK. If is selected, click the 'New' button, select JDK and then select the correct path to the JDK e.g. /opt/java/jdk1.8 or c:\Java\Jdk1.8

3.Corrupt JDK

There may be a problem with your JDK installation, re-install JDK

4.Re-import the project

Close the project if it is open in IntelliJ Delete the .idea folder in the project source code folder. Start IntelliJ and Import the project.

You can choose any of them which will work for you.

You need to add your external libraries/classes under dependencies in order for IDEA to see them when doing code analysis/autocomplete.

3

I faced a similar problem for no reason, I think it was caused by IDE(android studio). I have tried all of the above solutions but not worked. Finally, in my own situation, I solved this problem by the following actions:

  1. Delete your .idea folder in your local project.
  2. Reopen this project and just let Gradle run itself.

It was worked for me. I hope that my experience will be useful for you.

You can go to "File->Project Structure"

From "Project Settings", Select "Project" tab and there make sure that "Project SDK" has proper JDK selection.

enter image description here

After you add dependencies to POM file, make it a habit to refresh POM by clicking on the 'Reimports maven projects' icon. Its the first icon in the maven tool window located to the right of the main intellij editor. Its a blue icon with 2 circular arrows. Clicking it ensures that the added dependencies are fully integrated into your project

Run it from the project's root folder.

$ mvn -U idea:idea

One more advise would be to make sure that you import the project properly. If it's a maven project, import pom.xml and if it's a gradle project, import gradle.build file to make sure that all the dependencies are downloaded correctly.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy