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\'
I also got this error for multiple times when I try to build a new java project.
Below is the step how I got this stupid issue.
src/main/java.net.gongmingqm10.sketch.gradle wrapper, gradle idea to build the gradle stuff for the project.build.gradle file, and gradle build, reimport the project.User.java and School.java in the existing package net.gongmingqm10.sketchSolution:
Build the project first, and mark the main/java as the source root. Create a new directory with the same name net.gongmingqm10.sketch. Move all the files from the old troubling packages to new package.
Root cause:
Directory tree of source code
As you can see from the tree. I got a directory named net.gongmingqm10.sketch. But what we really need is the 3 levels directory: net->gongmingqm10->sketch
But before I finish building my project in Intellij, I create new directory named net.gongmingqm19.sketch, which will give me a real directory with the name net.gongmingqm10.sketch.
When we trying to import it. Obviously, how can intellij import the file under the weired directory with the name a.b.c.