我在Android Studio中有一个多模块项目,我想集成一个.aar
文件到一个模块中,该模块被引用作为App模块的库。项目结构如下:
- module1
- module2
- module3
- module4
- moduleApp
模块1被用作模块2中的库引用。
build.gradle module2
:
dependencies {
...
compile project(':module1')
}
Module2和其他模块被引用在App模块中。
build.gradle moduleApp
:
dependencies {
...
compile project(':module2')
compile project(':module3')
compile project(':module4')
}
我需要在module1中将一个.aar文件作为库文件进行集成,因为这是module1实现所必需的。我按照正常方式进行集成:
build.gradle module1
:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'package.name.of.aar:myLibrary@aar'
}
然而,当我运行
gradle sync
时,我收到了以下错误:failed to resolve package.name.of.aar:myLibrary@aar in module2
failed to resolve package.name.of.aar:myLibrary@aar in moduleApp
我该如何让module2和moduleApp找到.aar库?我应该在它们的build.gradle文件中包含更多内容吗?
transitive = true
。我会更新我的回答。 - RaGe