Android Import V7 Package common error, and project reference V7 package error Resolution

Source: Internet
Author: User

Android under V4 V7 V21 etc package is an extended support package for Android system, just like Windows system patch a reason .

Android expansion pack is mainly used to be compatible with the lower version, such as android3.0 after the emergence of Actionbar, if you want to use Actionbar, then the mobile phone system must be more than 3.0 to use, this will cause many users can not install the apk to lose users; (Some might wonder, why not just pack all the new stuff into the SDK, but provide a variety of support packages?) I understand that, for example: if the native Actionbar is packaged directly into the lower version of the SDK package, but the lower version of the phone does not have the relevant code, so even in the development of a compatible version, but run on the low version of the phone, the application to the system to find Actionbar, Found that there will be an error, so this practice is not possible)

Google developers to the high version of the new things made a lot of backward compatible support package, this is V4, V7 ... such as the role of the package, the realization of the principle is to imitate the high version of the new content, using the lower version to achieve (such as V7 package in the Actionbar, in fact, is a custom title bar, and then the title, logo, back key and so on, Assigning values to these controls or setting properties is a property name that mimics the native Actionbar, please follow my next blog--- replace native actionbar with Actionbarsherlock)

However, when I use the V7 package is not so smooth, here to summarize the use of the steps, errors encountered and solutions:

1. Import the V7 package:

eclipse--> Import--->existing Android Code into workspase--->D:\IDE\ANDROID64\sdk\extras\android\support\v7\ AppCompat;( After successful import, there will be a project in the workspace , open to look inside the content, found that the SRC directory is empty, why no code?) The original V7 package Java source code into a jar package , in the Project Libs directory The whole structure of the project is quoted V7-appcompat.jar, then a res directory, in fact, this res directory is the focus, if there is no res directory, the use of V7 package will not be so troublesome, directly V7-appcompat.jar is copied to the project, but there is no resource directory in the jar, which is why the V7 support package requires a library project to be used by developers. )

2. Next you will find that the V7 project reported an error:


Open Resource Directory, error, this is Android in order to compatible and adapt to different versions of the system and subdivided a number of values directory,values-v21 is the Android5.0 system loaded Resource directory (according to the suffix after the values, Can distinguish between different versions, different resolutions, different languages and so compatible with different versions, adapt to different screen sizes and different national languages, some people will try to remove these "superfluous" values package, will not error, but found that after the deletion of the new error, endless, And even if you delete all the errors, it is not possible to estimate the V7 package, so this solution is not feasible.

Just said that VALUES-V21 is the directory of Android5.0 load resources, but I found that my compiled version is 4.0, which is why the error, because the compilation version is 4.0, when the application compiled to hit the installation package, she does not think that the application will be installed on 5.0, because Target is 4.0, So it will not do anything for 5.0, and will not be packaged into the values-21, since it will not be packaged into, there is no value, so that the Android4.0 application should not exist in this values-21, so the error; The solution is to say that the build version increases to more than 5.0:

WORKAROUND: Simply increase the build to 5.0 (right-click-->properties--->project Build Target---> Tick 5.0 ——— >clean Library project)

3. Our Engineering Application Library project, or error, the same reason, because our project will be V7 Library project reference, I do your resources directory contains the V7 resource directory, there will also be values-v21, I have to will be our project compiled version raise to 5.0, and then Clean

4. after the completion of the above operation, found that the project is not wrong, but a run, there are errors:


It says that there are multiple Dex files in the Actionbar of the SUPPORT-V7 package, but this error is usually caused by the repeated introduction of the jar package;

then look at the project build path:

It turns out that two V4 and V7 packets were introduced , which is why?

Originally in our own project Libs has a V4 bag and a V7 package, and V7 Library project inside also, my project and quoted V7 Library project, so V7 Library project V4 and V7 package also introduced, so the project was repeated:

Find the reason, the problem is solved, open the project build Path,remove the two support packages in our project will be the line:

Run the project.

Android Import V7 Package common error, and project reference V7 package error Resolution

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.