AppCompat will always be a secondary library that's optional. If someone only wants to support one API level, then they should be able to use the appropriate platform features to do it. Android at its core still has to function. The support library is just an addition that's incredibly helpful.
If you think about the current state of things then yes this makes no sense. However, there will come a day (a long time in the future yes but it will be there) where v21 (for example) will be the lowest version of Android supported.
At this point, it would make sense to simply drop the shims in the support library which no longer need to be backported - for example see what the team have done with support v4 where a bunch of shims have been dropped because the min version of v4 has actually been raised to v9.
Hi, tech lead for the support library project here.
The support library has several goals, but one of the primary goals is to simplify developing for older platforms. Part of that involves creating API shims with smart fallback behavior (ex. ViewCompat) and part of that involves re-implementing functionality from newer versions to run on older platforms (ex. PopupWindowCompat).
Some features, like Fragments and Toolbar, are fairly self-contained and can be reimplemented in a way that doesn't depend on new APIs. You can check out the source code if you're curious.
Some features can't be backported entirely because of limitations of older platform versions. Elevation, for example, relies on changes to the hardware render; however, we are able to simulate elevation and shadows in some circumstances.
The same goes for loading Drawables that reference theme attributes -- this required a restructuring of the Resources framework that's not compatible with older platform versions and is difficult to fully backport because it depends on private implementation details. If you're really curious, this was one of my projects and I can go on at length about what changes were required and why it's not possible to create a stable, efficient backport of the feature.
To answer your last question, AppCompat helps bridge the gap between new and old versions of Android; however, because it is limited by the APIs available on existing versions it's very restricted in what it can accomplish.
If all Android devices were guaranteed to receive the latest OS updates forever, then you could make this case. New apps need to be prepared to run on older versions, thus AppCompat.
15
u/yohaq May 20 '16
On newer versions of android, appcompat will use the new versions of API's under the hood.
On old versions of android app compat will use shims to replicate the functionality using the old apis.
One implementation done by the developer, but full leverage of new api's on new, and full compatibility on old.
If they only added stuff into new API's, devs would have to back port stuff to older devices on their own, or code to just the older API's
15
u/alanviverette Android May 20 '16
Hi, tech lead for the support library project here.
The support library has several goals, but one of the primary goals is to simplify developing for older platforms. Part of that involves creating API shims with smart fallback behavior (ex. ViewCompat) and part of that involves re-implementing functionality from newer versions to run on older platforms (ex. PopupWindowCompat).
Some features, like Fragments and Toolbar, are fairly self-contained and can be reimplemented in a way that doesn't depend on new APIs. You can check out the source code if you're curious.
Some features can't be backported entirely because of limitations of older platform versions. Elevation, for example, relies on changes to the hardware render; however, we are able to simulate elevation and shadows in some circumstances.
The same goes for loading Drawables that reference theme attributes -- this required a restructuring of the Resources framework that's not compatible with older platform versions and is difficult to fully backport because it depends on private implementation details. If you're really curious, this was one of my projects and I can go on at length about what changes were required and why it's not possible to create a stable, efficient backport of the feature.
To answer your last question, AppCompat helps bridge the gap between new and old versions of Android; however, because it is limited by the APIs available on existing versions it's very restricted in what it can accomplish.
8
u/bamfomet May 20 '16
If all Android devices were guaranteed to receive the latest OS updates forever, then you could make this case. New apps need to be prepared to run on older versions, thus AppCompat.