模块依赖 - 程序包在编译时不存在

时间:2014-07-30 19:00:04

标签: java android intellij-idea dependencies android-annotations

我已经阅读了很多问题& SO中的答案,没有任何运气。示例:Module packages not found at compile time in IntelliJ

问题在于我是一个由以下形成的项目:

  • 模块A
  • 模块B
  • 模块C

模块B与模块A和模块C具有依赖关系。

因此模块B中的导入代码就像

import com.moduleA.Fragment1;
import com.moduleA.Fragment2;
import com.moduleA.SomeInterface;

这些行在" coding-time"中正确导入,我可以正确使用这些类。

然而,当我编译时,它崩溃了:

  

错误:(8,32)错误:com.moduleA不存在

我已尝试将此模块A添加为Android库,但对我来说不行,因为Android需要生成常量字段(http://tools.android.com/tips/non-constant-fields)。

我不知道还能做什么。

任何提示?

1 个答案:

答案 0 :(得分:0)

对于那些要求代码示例的人表示抱歉,但是它与Gradle版本一样基本。

我通过在项目中创建库项目来解决问题。所以模块A实际上是一个库。

我说由于非常量字段我无法使用库,但是这个错误是由AndroidAnnotations生成的,它解释了如何用它创建库模块:

https://github.com/excilys/androidannotations/wiki/Library-projects#referencing-ids-by-name

感谢。

相关问题