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\'
you can try invalidating the cache and restarting intellij, in many cases it will help.
File -> Invalidate Caches/Restart
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.
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.
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.
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.
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