Android v7 package import common errors, and project reference v7 package error solution, androidv7
In android, v4 v7 v21 and other packages are extended support packages for the android system. You just want to install windows System patches.
Android extension packages are mainly used to be compatible with earlier versions. For example, if actionbar is displayed after android 3.0, the mobile phone system must be later than to use actionbar, this will cause many users to be unable to install the apk, which will lead to loss of users. (Some may wonder, why not simply package all the new things into the sdk but provide various support packages? I understand it like this. For example, if the native actionbar is directly packaged into a lower version sdk package, but there is no relevant code in the lower version mobile phone, in this way, even if it is compatible with a lower version during development, but when it is running on a lower version mobile phone, the app will go to the system to find the actionbar and report an error if it does not, therefore, this approach cannot be implemented)
Google developers have made many backward compatible support packages for new things in the later version. This is v4, v7... the role of other packages, the implementation principle is to imitate the new content of the higher version, use the lower version to implement (for example, the actionbar in the v7 package is actually a custom title bar, the title, logo, back key, and so on are displayed. assigning values to these controls or setting attributes is the attribute name that imitates the native actionbar. For details, refer to my next blog-replacing the native actionbar with actionbarsherlock)
However, when I use the v7 package, it is not so smooth. Here we will summarize the steps, errors, and solutions:
1. Import the v7 package:
Eclipse --> Import ---> Existing Android Code Into Workspase --->
D: \ IDE \ ANDROID64 \ sdk \ extras \ android \ support \ v7 \ appcompat, the src directory is empty. Why is there no code? The original v7 package java source code into a jar package, in the project libs directory; the structure of the entire project is to reference the v7-appcompat.jar, and 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 copy the v7-appcompat.jar to the project on the line, but this jar package does not have a Resource Directory, this is why the v7 support package requires a library of projects for developers .)
2. An error is reported in the v7 project:
The res directory contains many values directories, which are subdivided by android to be compatible with and adapt to different versions of the system,
Values-v21 is the Resource Directory loaded by Android5.0 System (according to the suffix after values, you can distinguish different versions, resolutions, languages, and so on to be compatible with different versions, adapt to different screen sizes, and different languages.) Someone will try to delete these "redundant" values packages, no error is reported, but a new error is found after this error is deleted, and there is no end to it. Even if you delete all the errors, it is estimated that this v7 package is useless, therefore, this solution is not feasible.
I just mentioned above that the values-v21 is Android5.0 to load the Resource Directory, but I found that my build version is 4.0, that is why the error is reported, because the build version is 4.0, when the application is compiled and installed, she does not think that the application will be installed on 5.0. Because the target is 4.0, it will not do anything for 5.0, nor will it package values-21. since it will not be packed in, there is no value, so we think that this values-21 should not exist in the Android4.0 application, so an error is reported. The solution is to increase the compilation version to 5.0 or above:
Solution: you only need to increase the compilation version to 5.0.
(Right-click --> Properties ---> Project Build Target ---> check 5.0 ---> clean Library Project)
3. An error is still reported after our project application library project. In the same way, because our project references the v7 library project, i, your resource directory contains the v7 Resource Directory, there will also be a values-v21, etc., I have to increase our project build to 5.0, and then clean
4. After completing the above operations, I found that there was no error in the project, but an error was reported after the operation:
It says there are multiple dex files in the ActionBar of the support-v7 package, but this error is generally caused by repeated introduction of the jar package;
Let's take a look at the build path of the project:
We found that two v4 and v7 packages were introduced. Why?
It turns out that there is a v4 package and a v7 package under our own project libs, and there is also a v7 Library Project, and my project references the v7 library project,
In this way, the v4 and v7 packages under the v7 library project are introduced, so the project is repeated:
Find the cause and solve the problem. Open the build path of the project and Remove the two support packages in our project.
(Use the support packages introduced in the v7 Library Project ):
Run the project.