【问题标题】:Module dependency - package does not exist in compile time模块依赖 - 编译时包不存在
【发布时间】:2014-09-22 13:36:45
【问题描述】:

我在 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;

这些行在“编码时间”中正确导入,我可以正确使用这些类。

但是当我编译时,它崩溃了:

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

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

我不知道还能做什么。

有什么建议吗?

【问题讨论】:

  • 将项目上传到 github,包括所有 IntelliJ 配置文件会有所帮助...

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


【解决方案1】:

对于那些要求提供代码示例的人感到抱歉,但它与 Gradle 构建一样基本。

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

我说我不能使用库,因为非常量字段,但该错误是由 AndroidAnnotations 生成的,它解释了如何使用它创建库模块:

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

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2013-08-08
    • 2017-08-12
    • 1970-01-01
    • 2011-09-29
    • 2013-11-05
    • 1970-01-01
    相关资源
    最近更新 更多