Intellij Cannot resolve symbol on import

前端 未结 29 1742
耶瑟儿~
耶瑟儿~ 2020-11-30 18:10

This problem happens intermittently for different libraries and different projects. When trying to import a library, the package will be recognized, but the class name can\'

相关标签:
29条回答
  • 2020-11-30 18:55

    you can try invalidating the cache and restarting intellij, in many cases it will help.

    File -> Invalidate Caches/Restart

    0 讨论(0)
  • 2020-11-30 18:57

    I tried invalidating caches and restarting, but the only thing that worked for me was wiping out the .idea directory completely, then creating a new project from scratch.

    0 讨论(0)
  • 2020-11-30 19:01

    I had the same issue and the reason for that was incorrect marking of the project's sources.

    I manually created the Root Content and didn't notice that src/main/test folder was marked as Sources instead of Tests. So that is why my test classes were assumed to have all their test libraries (JUnit, Mockito, etc.) with the scope of Compile, not Test.

    As soon as I marked src/main/test as Tests and rebuilt the module all errors were gone.

    0 讨论(0)
  • 2020-11-30 19:02

    Simple Restart worked for me.

    I would suggest first try with restart and then you may opt for invalidating the cache.

    PS : Cleaning out the system caches will result in clearing the local history.

    0 讨论(0)
  • 2020-11-30 19:02

    What did it for me is to edit the package file in the .idea folder as I accidentally added sources to this jar library and android couldn't resolve it by deleting the sources line as marked in the b/m picture library error.

    Then rebuild the gradle and bam problem solved.

    0 讨论(0)
  • 2020-11-30 19:02

    in my case the solution was to add the project as maven project, besides the fact that i imported as maven project :P

    go to pom.xml -> right click -> add as maven project

    0 讨论(0)
提交回复
热议问题