在即时应用程序的每个模块中应该放置哪些依赖项? [英] What dependencies should one be putting in each module of an instant app?

查看:94
本文介绍了在即时应用程序的每个模块中应该放置哪些依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm in the process of writing an instant app for others to learn how to write an instant app and hoping to get some ideas on how to best structure the app for dependencies.

现在阅读有关项目结构的 Android开发人员文档并参考下图:

Now reading the Android developer docs on project structure and referencing the diagram below:

我想知道新的

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

基本功能

我当时认为基本功能模块中的几乎所有内容都应该使用api gradle配置,因为基本功能模块实际上可以编译为AAR库文件.我可能对此模块有一个问题,如果要使用ROOM,这是将其放入其中的模块吗?

I was thinking pretty much anything in the base feature module should be using the api gradle configuration since the base feature module essentially compiles down to an AAR library file. One question I might have for this module, if one was to use ROOM would this be the module to place it in?

功能

现在在功能模块中,据我了解,所有事物都应使用implementation gradle配置,因为这些模块不应在那里将依赖关系泄漏给任何其他模块,以真正使它们彼此独立.

Now in the feature modules, it is my understanding that everything should be utilizing the implementation gradle configuration since these modules should not leak there dependencies out to any other modules in order to truly make them independent from one another.

只需寻求对我的理解的确认,以及对项目有帮助的任何想法.如果您想查看我到目前为止得到的代码,请此处是github仓库.目前,这确实很简单,但我当时正在考虑使用Retrofit搞乱《星球大战》 API.

Just looking for some confirmation of my understanding and also any ideas to help with the project. Here is the github repo if you want to check out the code I got so far. It is really simple at the moment, but I was thinking about messing around with the Star Wars API using Retrofit.

如果您想尝试提出请求,请自己提出其他人应该知道的其他概念,谢谢您的帮助,并乐意接受任何贡献.

Thanks for any help and gladly accept any contributions if you want to to try and make a pull request yourself for any other concepts in making an instant app that others should know.

推荐答案

正如keyboardsurfer所述,您的依赖假设是朝正确的方向.

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

  • 基础位于根目录下,其行为就像是所有 非基本功能模块,因此应使用以下命令设置其共享依赖项 api,以便依赖它的模块也可以访问它们. (尽管,base不必只像库一样工作,它可以 本身也是一个功能APK)

  • 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)

功能,作为一个即时应用程序,每个应用程序都以其自己的APK延伸到最后,因此没有理由将其依赖项泄漏给任何其他模块,因此依赖项应该在此处使用implementation设置.

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.

Google示例中,cookie-api和install-api是一些更清楚地说明依赖性配置的示例用法,就像我上面解释的那样.

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.

这篇关于在即时应用程序的每个模块中应该放置哪些依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆