0

In my project, com.google and some other packages are highlighted in red with an error message "unresolved reference". enter image description here

However, I can still run and build the code on Intellij. Therefore, I suspect that Intellij cannot recognize the packages due to incorrect configuration. "Partially Sync" does not help,and I tried difference java version, e.g., java 8, java 11 and java 13 but still have the same problem. I also tried making all configuration match each other and invaliding caches, but it still does not work. Kotlin unresolved reference in IntelliJ Here is the screenshots of my configuration.

java compiler: enter image description here

kotlin compiler: enter image description here

project structure -- project: enter image description here

project structure -- module: enter image description here

project structure -- library: enter image description here

project structure -- facets: enter image description here

project structure -- SDK: enter image description here

潇洒张
  • 273
  • 2
  • 9
  • Have you told IntelliJ where to find the library with that class? From the screenshots, you don't seem to have downloaded it and added it to the project. Are you using a package manager such as Maven or Gradle (which is the usual way to manage this sort of external dependency)? (Also, when you say that you “can still run and build the code on Intellij”, is that a typo?) – gidds Jun 03 '23 at 20:49
  • In the WORKSPACE, I've added some com.google.xxx as dependencies, but I haven't added any specific com.google packages in class path. The class path only contains the default libraries from a downloaded JDK version. Although I can build and run my code, the code highlighted in red are quite bothersome and disruptive to my coding experience. And this issue makes it difficult for me to determine whether an API/library is available or not. – 潇洒张 Jun 03 '23 at 20:58
  • So I suspect that the dependencies are correct, since the code can be built and run. The problem is that Intellij cannot recognize some libraries, then it visualize such libraries as unresolved. – 潇洒张 Jun 03 '23 at 20:59
  • 1
    A folder name like “src” shouldn’t be part of a qualified class name. Are you sure that the class name isn’t `org.perses.ppr.PPRUtils`, without additional prefixes? – Holger Jun 05 '23 at 09:48
  • Is it reproducible with some sample project? – y.bedrov Jun 05 '23 at 21:50

0 Answers0