简体   繁体   English

有没有办法从项目 libs 文件夹中的另一个 aar 文件访问一个 aar 文件的方法

[英]Is there any way to access methods of one aar file from another aar file in project libs folder

I generated 2 aar files from 2 libraries generated by me and added in my main project by putting them in libs folder.我从我生成的 2 个库中生成了 2 个 aar 文件,并通过将它们放在 libs 文件夹中添加到我的主项目中。 Now i can able to access classes of the aar from main project.现在我可以从主项目访问 aar 的类。 But i want to call class of first aar from second.但我想从第二个调用第一个 aar 的 class。 Is it possible可能吗

The second aar would need the first aar as a dependency.第二个 aar 需要第一个 aar 作为依赖项。 You can get away with the first aar being compileOnly with the second aar, because the main project can provide the actual library.您可以避免第一个 aar 被compileOnly与第二个 aar,因为主项目可以提供实际的库。

I noticed one of the tags you have is modularization .我注意到您拥有的标签之一是modularization This kind of relationship between the 2 libraries is not modularization but tightly coupled they might as well be the same library.这两个库之间的这种关系不是modularization的,而是紧密耦合的,它们也可能是同一个库。

What you need to do is rethink your 2 libraries and how they are supposed to interact with the outside world.您需要做的是重新考虑您的 2 个库以及它们应该如何与外部世界交互。

If library 1 produces an output pass it to library 2, instead of library 2 retrieving it, itself.如果库 1 生成 output 将其传递给库 2,而不是库 2 本身检索它。

Your main app is the glue.您的主要应用程序是胶水。

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

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