The Android Support Library provides a JAR
file with an API library that allow you to use some of the more recent Android APIs in your app
while running on earlier versions of Android. For instance, the Support Library provides a version
Fragment APIs that you can use on Android 1.6 (API level 4) and
This lesson shows how to set up your app to use the Support Library in order to use fragments to build a dynamic app UI.
Set Up Your Project With the Support Library
To set up your project:
- Downlad the Android Support package using the SDK Manager
- Create a
libsdirectory at the top level of your Android project.
- Locate the JAR file for the library you want to use and copy it into the
For example, the library that supports API level 4 and up is located at
- Update your manifest file to set the minimum API level to
4and the target API level to the latest release:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
Import the Support Library APIs
The Support Library includes a variety of APIs that were either added in recent versions of Android or don't exist in the platform at all and merely provide additional support to you when developing specific application features.
You can find all the API reference documentation for the Support Library in the
platform docs at
import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; ...
When creating an activity that hosts fragments while using the Support Library, you must also
FragmentActivity class instead of the traditional
Activity class. You'll see sample code for the fragment and activity in the next