• Android Video Tutorials

Android - Support Library


Advertisements

When you develop an app on a latest version of android like 5.x and you also want it to run on those devices which are running older versions of android like 3.2 e.t.c. you can't do that until you add backward compatibility to your code.

To provide this backward compatibility android provides you the Android Support Library package. The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.

Including the Support Libraries in your Android project is considered a best practice for application developers, depending on the range of platform versions your app is targeting and the APIs that it uses.

Support Library Features

The Android Support Library package contains several libraries that can be included in your application. Each of these libraries supports a specific range of Android platform versions and set of features.

In order to effectively use the libraries, it is important to consider that which API level you want to target as each library supports different API level.

Following is a brief description of android support libraries and API level they support.

Sr.No Version & Features
1

v4 Support Library

This library is designed to be used with Android 1.6 (API level 4) and higher.

2

v7 Support Library

There are several libraries designed to be used with Android 2.1 (API level 7) and higher.

3

v8 Support Library

This library is designed to be used with Android (API level 8) and higher.

4

v13 Support Library

This library is designed to be used for Android 3.2 (API level 13) and higher.

Please Remember that use of Android Support Library in your app code is encouraged and preferred. By using these libraries you can increase your target market and target audience.

Downloading the Support Libraries

Please note that before installing the support library packages you should be clear that what feature you want to use in your app.

The Android Support Library package is available through the Android SDK Manager.

Follow the following steps to download the support library package through the SDK Manager.

  • Start the android SDK Manager.

  • In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder.

  • Select the Android Support Library item.

  • Click the Install packages button.

Android Support Library Tutorial

After downloading, the tool installs the Support Library files to your existing Android SDK directory. The library files are located in the following subdirectory of your SDK: /extras/android/support/ directory.

Choosing Support Libraries

Before adding a Support Library to your application, decide what features you want to include and the lowest Android versions you want to support.

Changes in Android build.gradle

If you are increasing the backward compatibility of your existing application to an earlier version of the Android API with the Support Library, make sure to update your application's build.gradle. Specifically, you should update the compileSdkVersion element in the build.gradle to the new, lower version number, as shown below −

android {
   compileSdkVersion 24
   buildToolsVersion "24.0.1"

   defaultConfig {
      applicationId "com.example.howcodex7.myapplication"
      minSdkVersion 23
      targetSdkVersion 24
      versionCode 1
      versionName "1.0"
   }
	
   buildTypes {
      release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
   }
}

This change tells Google Playstore app that your application can be installed on devices with Android minimum version of 23.

Advertisements