All possible solutions about Unable to resolve class in IntelliJ 2018.1 are listed in the article(based on my experience and tested with community edition):

You can check also : Intellij IDEA 2017 unable to resolve class Maven

Unable to resolve class in Intellij can be caused by several different reasons and respectively has several solution. The problem can impact different files and different libraries. If you import a library, the package will be recognized, but the class name can't be resolved. Your code will be working fine but you will see errors and warnings.

If you follow the the package's declaration, you will see all the classes displayed in the side pane, including the ones in error. Auto-complete import for this class , will not propose the class in the dropdown.

I tried invalidating caches already, doesn't work. I cannot find any class conflicts -- there is no other jar file in my classpath with the same package name. I am able to import this class into other projects.

Solution Invalidate Cache

The first thing to try is to invalidate the cache. Usually this problem occurs to me after updates or adding new libraries to the project. It could affect many classes.

  • Go to File
  • Invalidate Caches/Restart
  • You can choose only Invalidate and restart

PS : First try only restart and then you may try by invalidating the cache.
Cleaning out the system caches will result in clearing the local history.

Solution Check your module dependencies

This one has symptoms that impact only a single module. It happens after adding / removing new libraries to the project. It is cause by broken dependencies

  • Project Structure (Ctrl+Alt+Shift+S).
  • Modules
  • Select your problematic module.
  • Change tab on top of window "Dependencies".
  • Check dependencies - the required library (if you need to add specific library in the tab 'libraries') or module has listed here and it has right scope ( Change the scope to "Compile" rather than "Test").

Solution module source roots

Another reason for unable to resolve class is wrong module scope. In this case it is due to wrong source root issue. If the previous solutions didn't work for you then you can try:

  • Project Structure (Ctrl+Alt+Shift+S).
  • Modules
  • Select your problem module.
  • Change tab on top of window "Sources".

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

Solution class missing import

If only one class is not found in the code, then the problem could be missing import. You can imported by

  • mouse over the class(usually in red)
  • Press (Alt+Enter).
  • Choose the desired import

Solution setup JDK

You could see this error also if your setup is wrong for Java, Groovy, Scala. Then you can setup JDK by :

  • select Setup JDK from the intentions menu
  • click on Configure
  • click on the button ...and browse to the right JDK path
  • Go to File
  • Invalidate Caches/Restart