Android support and troubleshooting of Common Errors

Source: Internet
Author: User

Android support and troubleshooting of Common Errors
First, we need to understand what these packages are.

Google provides Android Support Library package series packages to ensure lower compatibility for sdk development in later versions. during Development of x, some features of the higher version can be used in versions such as 1.6, such as fragement and ViewPager. The following describes the differences between these versions:
  • Android Support v4: this package is designed to take care of version 1.6 and later. This package is the most widely used. It is provided by default when eclipse creates a new project.
  • Android Support v7: this package is designed to take care of versions 2.1 and later, but it does not include lower. Therefore, if you do not consider 1.6, you can add this package, v7 depends on the v4 package, that is, the two must be included at the same time.
  • Android Support v13: this package is designed for android 3.2 and later versions. It is generally not commonly used and can be used in tablet development.
Various problems encountered when importing these packages
  • If you need to use the Android support package in the project, you must put the support package under libs and then use it. But I encountered the following problem while using android-support-v7-appcompat.jar:
  • I use the v7 package, and the ActionBarActivity class is imported successfully, but it still cannot be used ~~
  • V7 is dependent on v4, and the two versions must be the same; otherwise, it cannot be used. Therefore, you only need to find resources of v4 and v7 on the Internet to use them together.
  • These support packages are included in the Android sdk at .. \ sdk \ extras \ android \ support. If you want to use a v7 package, just go to .. \ sdk \ extras \ android \ support \ v7 \ appcompat \ libs to get it. Not only is the version consistent, but the version is also consistent with the current sdk version
Possible problem 1: styles... No resource found
Res \ values \ styles. xml: 4: error: Error retrieving parent for item: No resource found that matches the given name 'Theme. appCompat. light. darkActionBar '. the no resource found problem generated in the values field indicates that there is no resource in v7.
  • Solution:

    Add a resource library. For the above example, AppCompat is in v7, so v7 resources are missing. Obtain from sdk. The path is sdk \ extras \ android \ support \ v7 \ appcompat. import this library through eclipse ). Then add the lib to the previous project and then clean it. In this way, the above problems can be solved.

Possible problem 2: values-v11, values-v21, values-v17 and so on under the No resource found
Appcompat \ res \ values-v21 \ styles_base.xml: 75: error: Error retrieving parent for item: No resource found that matches the given name 'android: Widget. material. actionButton '. appcompat \ res \ values-v11 \ themes_base.xml: 178: error: Error: No resource found that matches the given name: attr 'android: windowActionBar '. appcompat \ res \ values-v14 \ themes_base.xml: 27: error: Error: No resource found that matches the given name: attr 'android: actionModePasteDrawable '. for the problem that the resource cannot be found under values loaded for different android targets such as values-v11, the reason is the same, the resource under this target cannot be found
  • Solution:

    It's easy to put the project. in properties, the target = android-8 may be slightly higher, change it to target = android-21 or higher (provided that the sdk has downloaded the target Library), and then clean the project. This will solve these problems. Of course, you should not forget to add uses-sdk in Manifest to allow the lowest version.

 

Related Article

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.