Android 如何在应用程序模块中删除特定于模块的库和存储库?

Android 如何在应用程序模块中删除特定于模块的库和存储库?,android,gradle,module,Android,Gradle,Module,我正在将我的单模块应用程序模块化,但有一个问题我无法解决。 我有两个模块,让我们称它们为:app(com.android.application模块)和:library(com.android.library) 库模块依赖于另一个android库(播放器的brightcove sdk),其build.gradle如下所示: repositories { maven { url 'http://repo.brightcove.com/releases' } } dependencies {

我正在将我的单模块应用程序模块化,但有一个问题我无法解决。 我有两个模块,让我们称它们为:app(com.android.application模块)和:library(com.android.library)

库模块依赖于另一个android库(播放器的brightcove sdk),其build.gradle如下所示:

repositories {
   maven { url 'http://repo.brightcove.com/releases' }
}
dependencies {
   ...
   implementation "com.brightcove.player:exoplayer2:6.3.1"
}
My: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模块后,才能解决此问题。 但我并不想从“:library“in”:app”复制我所有aar依赖项的存储库,也不想将此“存储库”存储在顶级构建文件中


在多模块android应用程序中处理此类情况的正确方法是什么?

当你的应用程序想要访问库中使用的第三方时,你也应该将其依赖项添加到你的app build.gradle中。因为它们之间并没有像链条一样的联系,第三方只在你们的库中可见。因此,您应该在app build.gradle中添加以下内容:

dependencies {
     implementation "com.brightcove.player:exoplayer2:6.3.1"
}

谢谢你的回答。实际上,没有必要将此依赖项添加到:app模块。即使我只包含存储库{maven{url'}},而不在依赖项中添加库,它也可以正常工作。但这对我来说似乎有点奇怪。只要在库模块内部将
implementation
更改为
api
。此依赖关系将传播到
app
模块。