Android Studio 3 difference between library module and feature module

杀马特。学长 韩版系。学妹 提交于 2019-12-08 15:52:15

问题


In Android Studio 3 there are at least two new module types. First is Instant app module and the second one is feature module. With Instant App module it's quite obvious but feature module from my perspective is the same as the library module. So what is the real difference between library and feature modules and when I should use library module and when feature module?


回答1:


I would complete Marcin Orlowski scheme like this. You could picture library module in the same way as dependencies of a given feature or base module.

Hence the library modules will not be packaged in Instant APP APK.




回答2:


This all for Instant Apps so you only need it if you are making your app supporting instant app feature

See https://developer.android.com/topic/instant-apps/getting-started/structure.html#basic-app




回答3:


A feature module is a module that applies com.android.feature plugin.

This module type has a dual nature:

  • When consumed by an application (com.android.application) during build, it produces an aar and works just like a library

  • When consumed by an Instant App APK (com.android.instantapp), it generates an Instant App APK Developers should write feature modules just like library modules. The tools provided are responsible for applying the correct nature when used during a build.

In the simplest case an Instant app can have a single feature module. If there is more than one feature module, these feature-to-feature dependencies can be defined through the api configuration. In any case, there must only be a single base feature which is marked with a baseFeature attribute.

Main source: https://codelabs.developers.google.com/codelabs/android-instant-apps/#3




回答4:


Use Feature for linked feature of your instant app (to launch it with deeplink).

Use Library for code dependency in your app or in your Feature modules.




回答5:


Android SDK is the core features and software tools that allow you to create an app for the Android Platform. An SDK contains lots of libraries and tools which you will use to develop your application.

A Library is a collection of pre-built compiled code which you can use to extend your application's features. For example, you may need to show some graphics in your application. Instead of creating this from scratch, you may choose to use a pre-built library someone else has developed which will give you the features you need thus saving you some time.

A module is a small part of the application which can be tested and debugged on its own without needing the whole application. This is same for any programming language. Suppose you are building an app with Login feature. To test if the login feature works, you don't need the whole app. Thus the Login part is a module of your application.

The app module builds an app. A library module builds a library.

An app is what a user uses. The output of an app module is an APK, the package of an Android application.

A library is a collection of code that represents something that you want to use in multiple applications or otherwise want to keep in a separate "container" than the rest of the app code. The output of a library module is an AAR And Jar.



来源:https://stackoverflow.com/questions/44838108/android-studio-3-difference-between-library-module-and-feature-module

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