我想将我的库打包为 aar。
该库有几个依赖项(通用图像加载器、ORMLite、番石榴......)
它还依赖于我编写的另一个库(称为“库 B”)。
我有两个问题:
- 使用我的库的每个人是否都需要根据库的依赖项(通用图像加载器、ORMLite、guava...)添加依赖项
- 我是否需要为“库 B”创建一个单独的 aar,并让我的 lib 的用户对它有一个单独的依赖项?
我想将我的库打包为 aar。
该库有几个依赖项(通用图像加载器、ORMLite、番石榴......)
它还依赖于我编写的另一个库(称为“库 B”)。
我有两个问题:
Will everyone who will use my library need to add dependencies according to the library's dependencies (universal image loader, ORMLite, guava...)
Not if you are distributing your AAR as an artifact in a repository with appropriate metadata (e.g., Maven-style POM file). The metadata will point to your dependencies, and build systems (e.g., Gradle) will pull in the dependencies.
Do I need to create a separate aar for 'library B'
Yes, otherwise nobody will have access to it, unless you eliminate it and fold its code into your first library.
and have users of my lib have a separate dependency for it?
See above for setting up dependencies.
您不需要这样做,您只需执行以下操作:如果您的 aar 库有三十个依赖项:您应该让其他人以这种方式使用您的 aar 库:例如:
compile('com.android:com.android.download:1.3')
或者
compile('com.android:com.android.download:1.3@aar'){
transitive = true
}
如果您的 aar 库没有 30 个依赖项:
compile('com.android:com.android.download:1.3@aar')
总之:@aar 与传递的默认 Vault 有冲突