简体   繁体   English

导入多个相互依赖的 gradle 依赖项

[英]Importing multiple gradle dependencies which depend on each other

Supposing I have a project with dependencies on modules A and B .假设我有一个依赖于模块AB If module B internally is also dependent on module A , do I need to add them both to the original project or just adding dependency on module B would also allow access to module A?如果模块B内部也依赖于模块A ,我是否需要将它们都添加到原始项目中,或者仅添加对模块 B 的依赖也允许访问模块 A?

In your case, adding only the B module dependency will be sufficient .在您的情况下,添加B模块依赖项就足够了 Using either api or implementation (or even the deprecated compile ).使用apiimplementation (甚至不推荐使用的compile )。 You will be able to access code of A module through it even without explicitly specifing its dependency in your build.gradle file.即使没有在build.gradle文件中明确指定其依赖项,您也可以通过它访问A模块的代码。 Also, I would suggest you read this artice Implementation Vs Api in Android Gradle , as it goes more deep into the issue as well as explaining the differences between the api and implementation , which I mentioned earlier.此外,我建议您阅读这篇文章Implementation Vs Api in Android Gradle ,因为它更深入地探讨了这个问题,并解释了我之前提到的apiimplementation之间的差异。

你只需要导入依赖 B

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

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