Search code examples
androidandroid-support-librarybackwards-compatibility

Android support library, what is the most appropiate way of using it?


The support libraries allow us to use newer features even when using older versions of android, but I've noticed that they also work on newer versions.

  • Are we expected to detect the version and choose to use the support library version of a class only if the application is made to run in an older version?

  • Or is it appropiate to simply use the support library version of a class even in cases where the regular version would be available?

Right now I'm thinking the second option would be better as it would make the application simpler to read and understand, with less special cases. However are there any other pros and cons to consider?

Is there a third option?


Solution

  • We have both advantages and disadvantages on using Support library classes than Android Framework classes.

    Advantages :

    • It is updated much often. If any issue is found, it can be fixed on next release of support library. For framework , google will have to release another version of Android.
    • New APIs can be used on previous versions easily.

    Disadvantages :

    • Of course, APK size will increase.
    • "Which" support library to use is always a tedious task.

    So, I will prefer option 2

    Or is it appropiate to simply use the support library version of a class even in cases where the regular version would be available

    Also, If any new version is available , it is notified on Android Studio. We don't have to check manually if any update is available.