Search code examples
androidandroid-actionbarandroid-5.0-lollipopandroid-appcompatandroid-api-levels

Is it a good idea to forgo appcompat for a project with minimum API level 21?


I'm starting a project with a minimum API level of 21, trying to figure out the right way to implement the ActionBar. The official docs start with using the appcompat library, and the main advantage listed is that it preserves compatibility back to level 7. I don't even want pre-Lollipop installs. Should I use appcompat anyway? Is there any advantage or disadvantage to forgoing the appcompat library?


Solution

  • Is it a good idea to forgo appcompat for a project with minimum API level 21?

    Probably not.

    First of all, even if you now think you won't, you might still want to downgrade later.

    But even if that is not the case, it still provides features. Think of if as being able to upgrade to 24, 25, or 26 in the future without modifying your code.

    Appcompat is all about compatibility. The APIs will change less (likely) and you can use interfaces without having to manually check API versions.

    I need proof!

    Take getColor(int). It was deprecated with version 23. So with 21 you would still use it, with 23 you would (should) have to switch to getColor(int, Theme). ContextCompat of the support library would handle this version check for you.

    And this is just one sample.