Packaging Android AAR that has dependencies

北城以北 提交于 2019-12-24 02:43:26

问题


I want to package my library as an aar.

The library has several dependencies (universal image loader, ORMLite, guava...)

It also has a dependency for another library that I wrote (call it 'library B').

I have 2 questions:

  1. Will everyone who will use my library need to add dependencies according to the library's dependencies (universal image loader, ORMLite, guava...)
  2. Do I need to create a separate aar for 'library B', and have users of my lib have a separate dependency for it?

回答1:


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.




回答2:


You don not need do that,and you only do the next: if you aar libray have thirty dependencies: you should make others use your aar library in the way: for example:

compile('com.android:com.android.download:1.3')

or

compile('com.android:com.android.download:1.3@aar'){
       transitive = true
}

if your aar libray have not thirty dependencies:

compile('com.android:com.android.download:1.3@aar')

In a word:@aar have conflict with the default vault of transitive



来源:https://stackoverflow.com/questions/27890037/packaging-android-aar-that-has-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!