【发布时间】:2018-09-21 16:30:03
【问题描述】:
我正在模块化我的单模块应用程序,但我遇到了一个我无法处理的问题。 我有 2 个模块,我们称它们为 :app (com.android.application 模块) 和 :library (com.android.library)。
:library 模块依赖于另一个 android 库(播放器的 brightcove sdk),它的 build.gradle 看起来像:
repositories {
maven { url 'http://repo.brightcove.com/releases' }
}
dependencies {
...
implementation "com.brightcove.player:exoplayer2:6.3.1"
}
我的 :app 模块只依赖于 :library 模块
dependencies {
implementation (':library')
}
但问题是在同步期间 IDE 向我抱怨
Error:Unable to resolve dependency for ':app@debug/compileClasspath':
Could not resolve com.brightcove.player:exoplayer2:6.3.1.
只有在将相同的存储库添加到 :app 模块后才能解决它。 但我真的不想从 ':app' 中的 ':library' 复制所有 aar 依赖项的存储库,也不想将这个 'repositories' 存储在顶级构建文件中。
在多模块 android 应用程序中处理此类情况的正确方法是什么?
【问题讨论】:
-
只需在库模块中将
implementation更改为api。并且这个依赖会传播到app模块。