问题
Android recently came out with a new com.android.feature
plugin to be used to split up applications into features for the new Instant apps. It seems to be an architecture they are recommending in general, not just for features you are splitting up for instant apps. You can do some reading about it's usage here.
What I'm failing to understand is what this plugin actually does better / differently than the normal android-library
plugin. I ask, because my team is legitimately considering splitting up our code into feature modules, for reasons that have nothing to do with Android instant apps, and I'm not understanding what the benefit to using the com.android.feature
plugin is.
回答1:
Update (as of May 2019): for anyone stumbling on this post, the details below are largely out-of-date now. The feature plugin (com.android.feature
) is no longer "new" and is actually now being deprecated in favour of instant-enabled App Bundles. Read more on that in the official blog post.
The new feature plugin (com.android.feature
) is actually almost identical to the existing library plugin (com.android.library
) in the way it behaves and the way it's used.
The key difference is that the library plugin will always output an Android Archive (AAR
) file where the feature plugin is able to output an AAR
file when the build targets a regular Android application (via plugin com.android.application
) and an APK
file for that module when the build targets an Instant App (via plugin com.android.instantapp
).
What are the benefits right now? Currently you only need to use the feature plugin to build for Google Play Instant (previously called Android Instant Apps). There are minimal benefits right now to using the feature plugin if you are NOT planning to build for Google Play Instant. One minor benefit might be you can output APKs
for each module of your app and could install and test them independently.
来源:https://stackoverflow.com/questions/44361335/why-use-the-new-android-feature-plugin-over-the-library-plugin