The CommonsBlog


Breaking Up (an Artifact) Is (Not That) Hard To Do

If you are like me, you missed the announcement about v24.2.0 of the Android Support Library being released last week. This release has an interesting change: support-v4 is being chopped up into smaller modules.

support-v4 still exists. However, rather than being a library itself, support-v4 relies upon transitive dependencies to pull in a series of other modules that, in aggregate, cover what the standalone support-v4 used to:

  • support-compat: for most of the ...Compat classes

  • support-media-compat: media-specific backports

  • support-fragment: the android.support.v4 implementation of fragments, including FragmentActivity

  • support-core-ui: other stuff not listed above that has a UI, such as ViewPager

  • support-core-utils: other stuff not listed above, such as FileProvider

If you use support-v4, nothing really changes. However, now you can start requesting the individual modules that you need. This is reminiscent of how play-services was broken up into lots of smaller modules a couple of years ago, so developers could pull in only the pieces that were needed.

The idea is that you should wind up with smaller APKs as a result, as you are not pouring lots of extraneous code into your project, then hoping that tools like ProGuard can get rid of that stuff.

In practice, the results will be mixed. For example, support-fragment requires all the rest of the current modules, so changing from support-v4 to support-fragment will have no significant impact. Modules like appcompat-v7 will need support-fragment, and so you will wind up with the extra ~1MB of APK bloat anyway if you are using appcompat-v7.

If you publish a large library, you could do the same sort of thing as Google did with support-v4. Reorganize your source into discrete modules, with appropriate cross-module dependencies. If needed, have a placeholder artifact representing the entire library that pulls in all of the new modules, but adds little to no code of its own. In general, having smaller libraries helps with APK size; having the “kitchen sink” artifact makes it easier for newcomers to get going with the library.


If your training firm is in need of an expert Android trainer to handle public training classes, contact Mark Murphy, as he may be able to help!