android - 应该在即时应用程序的每个模块中放置哪些依赖项?

标签 android module android-instant-apps android-architecture

我正在为其他人编写一个即时应用程序,以学习如何编写一个即时应用程序,并希望获得一些关于如何最好地构建应用程序以实现依赖项的想法。

正在阅读 Android developer docs on project structure并引用下图:

enter image description here

我想知道新的 gradle 3.0 dependency configurations , 哪些库应该存在于哪些模块中?

基本特征

我在想基本功能模块中的几乎所有内容都应该使用 api gradle 配置,因为基本功能模块基本上编译成 AAR 库文件。我可能对这个模块有一个问题,如果要使用 ROOM,这个模块会放置它吗?

特征

现在在功能模块中,我的理解是一切都应该使用 implementation gradle 配置,因为这些模块不应该泄漏依赖到任何其他模块,以便真正使它们独立于另一个。

只是寻找一些对我的理解的确认,以及对项目有帮助的任何想法。 Here是 github 存储库,如果您想查看我目前获得的代码。目前它真的很简单,但我正在考虑使用 Retrofit 来搞乱 Star Wars API。

感谢您提供的任何帮助,如果您想尝试自己提出拉取请求以获取其他人应该知道的即时应用程序的任何其他概念,我们将非常乐意接受任何贡献。

最佳答案

您问题中的共享详细信息是正确的。考虑以下一些建议,这些建议增加了 TWL 提到的要点:

  • 将某些库添加到特定的功能模块中 仅包含在功能模块中,而不是添加到 基础 APK。

For example, let's say you have an application that depends on libraries X, Y, and Z. Initially, you may pack all the libraries in the base module by placing all the dependencies in the base gradle.build file. But if only the code in the feature module requires library Z, it makes sense to move that dependency from the base module to the feature module.This works as long as no other feature modules depend on the same library. If multiple feature modules use the same library it definitely makes sense to keep it in the base module.

enter image description here

  • 处理传递依赖。

Transitive dependencies occur when the library your project relies upon depends on another library, which in turn may depend on yet another library. Sometimes those transitive dependencies may contain unexpected surprises such as libraries you do not need at all (i.e. a JSON processing library you never use in your code.)

我希望这能为您的查询添加一些信息,

I'm wondering with the new gradle 3.0 dependency configurations, what libraries should live in which modules?

还可以引用其中一些链接以获取其他数据:
Android Instant Apps(best-practices)
AIA structure

关于android - 应该在即时应用程序的每个模块中放置哪些依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48355277/

相关文章:

android - 在android中获取联系人的公司名称?

Python PIL - 无法在 Windows 8 上使用 Python3.3 显示图片

php - 如何在 Drupal 7 中以编程方式获取具有特定字段的所有内容类型?

android - 模拟器 Nexus5X And​​roid 8.0 Instant App

android - 是否可以在模拟器上使用已发布的即时应用程序(BuzzFeed、Wish 等)?

android - RecyclerView 何时使用 ItemDecoration 与 onBindViewHolder

java - 在不是 Activity 的类中使用 Android 中的 TelephonyManager

android - 创建持久通知并阻止状态栏中的通知

python - 在 Python 中自动下载所需模块的最简单方法?

java - 如何在Instant Apps中实现Multi Dex?