Add Android Compatibility Pack (V4, V7 AppCompat) to eclipse

Source: Internet
Author: User
Tags android sdk manager

How to select a Compatibility Pack,

Please refer to Android support Library Features (ii)

First, download the support Library

Method 1: Right-click project → select Android Tools→add support Library ...

Method 2:

Get the support Library from the SDK Manager:

1. Open the Android SDK Manager

2. In the SDK Manager window, scroll to the end of the package list, locate the extra folder, and open the folder to display its contents if needed.

3. Select the Android support Library project.

Note: If you are using Android Studio development, select and install the Android support repository project instead of the Android Support Library project.

4. Click the Install packages button.

When the download is complete, the SDK installs the support library file into your existing Android SDK directory. The library file is located in the following subdirectory of the SDK: <sdk>/extras/android/support/directory.

Second, add V4 Compatibility Pack (V4 Appconpat)
    1. Make sure you have downloaded the Android support Library using SDK Manager .
    2. Create a libs/directory in the root directory of your project .
    3. Copy the jar file from your Android SDK installation directory (for example, <sdk>/extras/android/support/v4/android-support-v4.jar) to your project's libs/directory.
    4. Right-click on the jar file and choose Build path > Add to build Path.
Third, add V7 Compatibility Pack (V7 Appconpat)

Create a library project based on the Support library code:

    1. Make sure you have downloaded the Android support Libraryusing SDK Manager.
    2. Create a library project and make sure that the required jar files are included in the project's Build path:
      1. Select File > Import.
      2. Select Existing Android Code into Workspace and click Next.
      3. Browse the SDK installation directory and enter the support library directory. For example, if you want to add a AppCompat project, browse <sdk>/extras/android/support/v7/appcompat/.
      4. Click Finish to introduce the project. For the V7 AppCompat project, you will see a new project titled Android-support-v7-appcompat .
      1. In the new project, expand the libs/folder, right-click each of the. jar files, and select build path > Add to build Path. For example, when you create a V7 AppCompat project, both the Android-support-v4.jar and Android-support-v7-appcompat.jar files are added to the build path.
      2. Right-click on the Library project folder and choose Build path > Configure build Path.
      3. In the Order and export option, tick the. jar file that you just added to the build path, and these files become available to the project and depend on the library project. For example, the AppCompat project requires both Android-support-v4.jar and Android-support-v7-appcompat.jar files to be exported.
      4. Remove the checkmark on the Android Dependencies .
      5. Click OK to complete the setup

Now that you have a library project with the support library of your choice, you can take advantage of this support library in one or more application projects.

Now we're going to add the library to the application engineering (the project that needs to join the support library):

    1. Right-click your project in the project browser and select Properties.
    2. In the category panel on the left, select Android.
    3. In the Library panel, click Add.
    4. Select the library item and click OK. For example, the AppCompat item is displayed as Android-support-v7-appcompatin the list.
    5. In the Properties window, click OK.

Problems encountered:

1, Java.lang.noclassdeffounderror:android.support.v7.appcompat.r$attr

This problem is due to the fact that the app did not find the corresponding V7 compatibility package at run time, please add V7 Compatibility Pack (V7 Appconpat) in the reference article

2. Java.lang.IllegalStateException:You need to use a theme.appcompat Theme (or descendant) and this activity.

After completing the 1,3 steps mentioned above, modify Android:theme to @style/theme.appcompat

Reference links

Android Support Library (i)

Android support Library Features (ii)

Android Support Library Setup (iii)

Support Library

Add Android Compatibility Pack (V4, V7 AppCompat) to eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.