What dependencies should one be putting in each module of an instant app?

五迷三道 提交于 2019-12-05 11:52:00

Shared details in your question are correct. Consider some of the below suggestions which add to the points mentioned by TWL:

  • Adding certain libraries to specific feature module which should be included in the feature module only, instead of being added in the base 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.

  • Taking care of Transitive dependencies.

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 hope this adds some information to your query,

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

Some of these links can also be referred for additional data:
Android Instant Apps(best-practices)
AIA structure

As mentioned by keyboardsurfer, your dependency assumption is in the right direction.

  • Base is at the root and acts like a library shared by all the non-base feature modules, so its shared dependencies should be set with api so that modules that depend on it can also access them. (though, base doesn't have to act only like a library, it can also be a feature APK itself)

  • Features, as an instant app, each one extends out to the end as its own APK, so there's no reason it should be leaking its dependencies to any other modules and therefore dependencies should be set with implementation here.

Within the Google Samples, the cookie-api and install-api are some samples that more clearly demonstrate the dependency configuration usage as how I explained above.

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