Intellij Cannot Resolve Symbol on Import

Intellij Cannot resolve symbol on import

There can be multiple reasons for this. In my case it was wrong source root issue. Invalidate caches didn't work along with other solutions.

Check your module source roots.

  1. Project Structure (Ctrl+Alt+Shift+S).

  2. Modules

  3. Select your problem module.

  4. Change tab on top of window "Sources".

  5. Remove unwanted source roots. Keep one and add src and test source roots in this root.

Cannot resolve symbol in Intellij IDEA

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

IntelliJ inspection gives Cannot resolve symbol but still compiles code

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.

IntelliJ cannot resolve any symbols or methods

The answer was the look through the pom.xml file line by line, and see what the dependencies were that I didn't have. I thought it was a configuration issue, but it wasn't.

I didn't notice that I didn't have the lombok plugin, which was a dependency for my project.

The problem listed in EDIT2 wasn't actually an issue since all of the classes were available.

IntelliJ inspection gives Cannot resolve symbol but still compiles code

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.

IntelliJ IDEA: cannot resolve symbol for String, System and other Java classes

Check the JDK configuration Classpath tab in Project Structure | SDKs:

JDK

Also check that project and modules use the same JDK.

If it's empty, remove the JDK and add it again. It's not recommended to use JetBrains Runtime as your JDK, download and configure some different standalone JDK instead, 2020.1 version can download JDK for you.

Important notice
The bundled JRE is used for running the IDE itself,
and it's not sufficient for developing Java applications. Before you
start developing in Java, download and install a standalone JDK build.



Related Topics



Leave a reply



Submit