Module packages not found at compile time in Intel

2019-04-21 20:38发布

问题:

I'm attempting to setup my Android project in IntelliJ. I've never used it before, and I'm having some problems with module dependencies.

The project depends on several modules, which I have added in the Dependencies tab. IntelliJ detects them (i.e. there are no complaints in the code), but it fails at compile time with "package x.y.z does not exist." I have also tried checking "export" for the modules, but that seems to have no effect.

I saw this question which appears to be the same problem, but there was no solution.

回答1:

Try adding your src as modules.

  • File > Add Module
  • Create Module from Existing Sources -> your_src_path_top_level
  • Next > Next > Finish
  • File > Project Structure > Modules > YourApp
  • plus button > Module Dependency > your_lib_you_added_earlier
  • Use the up/down arrows to move to the bottom of the list

Here is a visual where I have added the Google Play src as a module.