I also got this error several times when I try to create a new java project.
Below is the step how I got this stupid problem.
- Create an empty project and create a new
src/main/java directory. - Create the source package
net.gongmingqm10.sketch . - Use
gradle wrapper , gradle idea to create gradle material for a project. - Add some dependencies to the
build.gradle file and gradle build , reimport project. - Create
User.java and School.java in the existing net.gongmingqm10.sketch package - I got an error while I try to use Import School in User.java.
- Intellij continues to complain, cannot allow import of the character.
Decision:
First create a project 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 problematic packages to the new package.
The root cause:
Source Tree Directory Tree
As you can see from the tree. I got a directory named net.gongmingqm10.sketch . But we really need a directory with three levels: net-> gongmingqm10-> sketch
But before completing the project in Intellij, I create a new directory called net.gongmingqm19.sketch , which will give me a real directory named net.gongmingqm10.sketch .
When we try to import it. Obviously, how can I import a file under an element directory called abc .
Ming Gong Aug 19 '16 at 17:59 2016-08-19 17:59
source share