Package name does not correspond to the file path - IntelliJ

Android developer picture Android developer · Oct 18, 2014 · Viewed 106.1k times · Source

I'm trying to import a project from VCS (well, I'm doing it for the first time actually) and this is my (imported) project's structure:

The file structure

BTW. this screen is made after many tries of changing these directories' properties (in their context menus).

In these source files' I have a following error:

The error in the editor

One time it had nothing against badugi.client but it reported this error only in badugi.server. I have completely no idea how it works...

Also classes in the same directories do not see each other.

Error

This is a code from ClientWorker class which is located (as you can see in the first image) in the same directory as Server so it should know what Server is.

I'm pretty sure this code worked well in my friend's IDE. How do I configure IntelliJ to make it work?

Answer

Trann picture Trann · Jul 7, 2015

I had this same issue, and fixed it by modifying my project's .iml file:

From:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src/wrong/entry/here" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
  <excludeFolder url="file://$MODULE_DIR$/target" />
</content>

To:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
  <excludeFolder url="file://$MODULE_DIR$/target" />
</content>

Somehow a package folder became specified as the root source directory when this project was imported.