A summary of APPCOMPAT_V7 error problems when creating new Android projects

Source: Internet
Author: User

Next to my solution:

1. Ensure that the target version of the AppCompat project is below the Android version of the actual project

2. Make sure that the AppCompat project code is the same as the Eclipse tool code, and I made this mistake, causing the reference appcompat to always fail ...

My eclipse environment is utf-8 encoded, but the AppCompat project is created by default GBK encoding, right-AppCompat project >> Properties >>Resource>> change code to Utf-8

3. Make sure your project and AppCompat class library are workspace in the same workspace, and it's easy to get an error if you're not together .... This is the truth ....

Here is an excerpt from the network

One, dependence/detachment AppCompat

In the new version of Google with a new dependency package, this package contains V4 and V7 things (V7 is to rely on V4 This package, so use V7 must use together v4), as long as your compiled version compile With is 4.0 above, then the default depends on the AppCompat package, you can not get out of it anyway. If you're going to leave him, you can build a compiled version of an application such as 2.3,2.2, so you don't rely on the package.

Based on practical experience, we can no longer build a 2.x platform application, so we have to get along well with this appcompat. So we should understand the following points:

1.appcompat will make an error when deleted, it will be generated automatically after the new project.

2.appcompat will affect your R file and you may lose the R file when you cancel your dependency. The workaround is to delete or modify the XML file incorrectly before you can regain the R file

3.appcompat has its own properties, if you define the attribute property and it has the same name, then you have to change the names. This is the point of the Android egg ache, should pay attention to.

4.appcompat has its own version of the build, if its version is high, your program version is low, so that you are dependent on the problem of finding resources can not be found. So keep it consistent or higher than the build version. Of course you can also modify the compiled version of it.

Ii. supportV4 Packet Conflict

Program error said that the application of V4 and AppCompat in the V4 inconsistent. This is common because appcompat are frequently updated, so it is easy to appear inconsistent. The solution is to remove the dependencies, delete your own v4, and then go to the build path----Library, delete the private library, and then add the dependencies again. Of course the key point is to try not to make an error in the XML file, so it is difficult to regenerate the R file.

Iii. Resource errors in AppCompat

This error is basically the result of the update, because the new resource file is updated, but your AppCompat compiled version is still old, you can fix the problem by improving its compiled version in the AppCompat property and then cleaning it up. But then comes the problem of projects that depend on it, as well as the need to improve the build. Of course, you can also keep the appcompat you have not upgraded before, depending on the situation depends on it.

The following are the pioneering ideas used:

Prior to the previous 3.0 version to use Actionbar, must use the foreign Daniel wrote actionbarsherlock this open source project. After this year's Google/io conference, Google officially added Actionbar to the ANDROID-SUPPORT-V7 package, Started to let the 2.1 version support Actionbar, since then the most popular Android open source project Actionbarsherlock can exit the historical stage.

It is easy to use the V7 bag in Actionbar, but there is one place to pay attention. Some people may have just started to import Android-support-v7-appcompat.jar into the project, but will error when setting activity Theme, indicating "@style/theme.appcompat" is not found. This is because we are going to import V7 and resource files together.

Specific steps to use (for Eclipse):

Create a library project based on the Support library code:

  1. Make sure has downloaded the Android support Library using the SDK Manager.
  2. Create a library project and ensure the required JAR files is included in the project ' s build path:
    1. Select File > Import.
    2. Select Existing Android Code into Workspace and click Next.
    3. Browse to the SDK installation directory and then to the support Library folder. For example, if is adding the appcompat project, browse to <sdk>/extras/android/support/v7/appcompat/ .
    4. Click Finish to import the project. For the V7 AppCompat project, you should now see a new project titled Android-support-v7-appcompat.
    5. The new library project, expand libs/ the folder, right-click each .jar file and select Build Path > Add to Bui LD Path. For example, when creating the V7 AppCompat project, add both the and android-support-v4.jar files to the android-support-v7-appcompat.jar build path.
    6. Right-click the project and select Build path > Configure build Path.
    7. In the Order and Export tab, check the .jar files you just added to the build path, so they is available to Pro Jects that depend in this library project. For example, the appcompat project requires your to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
    8. Uncheck Android Dependencies.
    9. Click OK to complete the changes.

You are now having a library project for the your selected support library so you can use with one or more application projects.

ADD the library to your application project:

    1. In the project Explorer, right-click your project and select Properties.
    2. In the Library pane, click Add.
    3. Select the Library project and click OK. For example, the appcompat project should is listed as Android-support-v7-appcompat.
    4. In the Properties window, click OK.

Once your project is a set up with the support library, here's how to add the Action bar:

    1. Create your activity by extending ActionBarActivity .
    2. Use (or extend) one of the Theme.AppCompat themes for your activity. For example:
      <activityandroid:theme="@style/theme.appcompat.light">   

Now your activity includes the action Bar is running on Android 2.1 (API level 7) or higher.

On API level one or higher

The action Bar is included with all activities Theme.Holo so use the theme (or one of it descendants), which is the default th The EME when either the targetSdkVersion or minSdkVersion attribute are set to "11" or higher. If you don't want the action bar for a activity, set the activity theme to Theme.Holo.NoActionBar .

The above is from the Android website.

A summary of APPCOMPAT_V7 error problems when creating new Android projects

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.