13

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.

spierce7
  • 14,797
  • 13
  • 65
  • 106
  • 1
    Please also check out https://developer.android.com/topic/instant-apps/getting-started/structure.html and https://stackoverflow.com/questions/44838108/android-studio-3-difference-between-library-module-and-feature-module – Prags Oct 27 '17 at 05:16
  • 2
    What is the difference between **feature** and **dynamic-feature**? – IgorGanapolsky Aug 23 '18 at 10:39

1 Answers1

25

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.

AdamK
  • 21,199
  • 5
  • 42
  • 58
  • Is this totally different from **dynamic delivery**? https://developer.android.com/guide/app-bundle/configure – IgorGanapolsky Aug 23 '18 at 10:43
  • 2
    @IgorGanapolsky - it isn't totally different, but it is different. Actually the plugins are quite closely related (with `com.android.dynamic-feature` being based off the learnings of `com.android.feature`), plus the actual project structure will end up being quite similar. Given this, hopefully in the future these two plugins will be brought together into one plugin that supports both. – AdamK Aug 23 '18 at 10:53
  • Thanks for explaining. Right now, Google's Topeka app sample uses **com.android.feature**, whereas Android-Dynamic-Features sample uses **com.android.dynamic-feature**. So both samples have kind of a similar approach... – IgorGanapolsky Aug 23 '18 at 12:50
  • Yes exactly, very similar approach and project structure but still different plugins (and different output). Hopefully they will be merged in the future. – AdamK Aug 23 '18 at 23:02