简体   繁体   English

无法附带依赖项运送.aar吗?

[英]Impossible to ship .aar with dependencies?

I'm trying to create an Android library called MyLib. 我正在尝试创建一个名为MyLib的Android库。

The library depends on several other libraries and modules: A, B and C. 该库依赖于其他几个库和模块:A,B和C。

It seems that when my MyLib.aar is created that A, B and C are not included. 似乎在创建MyLib.aar时,不包括A,B和C。

When I integrate my MyLib.aar in to an app I must set A, B and C as dependencies in the app's build.gradle. 当我将MyLib.aar集成到应用程序中时,必须在应用程序的build.gradle中将A,B和C设置为依赖项。 But I already set them as dependencies in the MyLib library project. 但是我已经在MyLib库项目中将它们设置为依赖项。

Is this the correct behavior? 这是正确的行为吗?

Is there any way to package A, B and C with MyLib so that an app that depends on MyLib will not need to explicitly declare A, B and C as dependencies? 有什么方法可以用MyLib打包A,B和C,以便依赖MyLib的应用程序无需显式声明A,B和C为依赖项?

So if I want to distribute MyLib to other developers and have them be able to resolve the dependencies in their build environments, then it sounds like a solution would be to create a public Maven repo holding the dependencies of MyLib and then the dev using the library would be able to resolve all dependencies. 因此,如果我想将MyLib分发给其他开发人员并让他们能够解决其构建环境中的依赖关系,那么听起来解决方案是创建一个公共的Maven存储库,其中包含MyLib的依赖关系,然后使用该库进行开发将能够解决所有依赖关系。 Am I understanding that correctly? 我理解正确吗?

Generally speaking, yes. 一般来说,是的。

The AAR itself, and its POM file, would be hosted by a repository, one that is visible to whatever developers need the AAR. AAR本身及其POM文件将由一个存储库托管,任何开发人员需要AAR都可以看到该存储库。 That could be an in-house repository for a team, all the way up to something like Maven Central. 这可能是团队内部的仓库,一直到Maven Central之类的地方。

The dependencies of the AAR will then fall (hopefully) into two camps: 然后,AAR的依赖项将(希望地)分为两个阵营:

  1. Those that are already publicly-visible dependencies (eg, out on Maven Central), which consumers of your AAR/POM will be able to pull down 那些已经公开可见的依赖项(例如,在Maven Central上),您的AAR / POM的消费者将能够拉低这些依赖项

  2. Those that are your own code, which you would then treat like the AAR itself, putting the dependency and its POM in the repo, so others can get at it when they consume the primary AAR from the repo 那些是您自己的代码,然后您将它们像AAR本身一样对待,将依赖关系及其POM放入存储库中,以便其他人在从存储库中使用主AAR时就可以使用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM