Hello World Android App, Error: workspace\appcompat_v7\res\values-v21\styles_base.xml No resource found that matches the given name

前端 未结 8 548
耶瑟儿~
耶瑟儿~ 2020-12-15 05:36

I am a totally newbie who just got into Android development. I am going through the \"Building your first app\" tutorial on the official Android developer webpa

相关标签:
8条回答
  • 2020-12-15 06:06

    This is because of Eclipse and SDK relation upon the "appcompact_v7" library project.

    When we create a new Android Application Project, eclipse try to add a library(appcompact_v7) project for it.If we create our project with target 19 (API 19), eclipse will also generate the appcompact_v7 library project with API 19. When we clean and build the application, we got error like as follow:

    ....\appcompat_v7\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_v7\res\values-v21\styles_base.xml:79: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
    ....\appcompat_v7\res\values-v21\styles_base.xml:83: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
    ....\appcompat_v7\res\values-v21\styles_base.xml:25: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
    ....\appcompat_v7\res\values-v21\styles_base.xml:29: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
    

    Why? Because when eclipse create appcompact_v7, it retrieve all reference for every SDK version from your SDK manager. So, in appcompact_v7, there will be reference for SDK which is greater than API 19.

    Ok, check this part in the log: appcompat_v7\res\values-v21\styles_base.xml:75. That shown, it can't compile reference for values-v21(means target 21(API 21)). Therefore, it shown error like that.

    So, what we need to do. We need to do is, the compile target for appcompact_v7 project always must be the latest API of the related SDK.

    I also found this error because my latest is API 23 and I compile it wit API 22. So, I got this error:

    ....\appcompat_v7\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
    ....\appcompat_v7\res\values-v23\styles_base_text.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
    

    So, I change the android target in project.properties of appcompact_v7 to latest as follow:

    Also in project.properties of project as follow:

    After that, I clean and compile the project. It has shown no error.

    0 讨论(0)
  • 2020-12-15 06:11

    I found the source of the problem, when we create a new project, it contains the reference of the appcompat_v7 library:

    enter image description here

    the appcompat_v7 library already contains the support library "android-support-v4.jar"

    enter image description here

    the problem is that the new project created contains into the /libs folder, the library "android-support-v4.jar" too!, just delete this .jar from your new project ( that is already contained into the appcompat_v7 library)

    don´t forget to clean and build your project

    This problem happens using API 19 use API 21 or later

    0 讨论(0)
  • 2020-12-15 06:12

    See if this helps:

    1. In Eclipse, right click on current project, click on Import... then choose General > Existing Projects into Workspace.
    2. Use "Select root directory:" and browse for local folder containing "adt-bundle-windows" in pathname, which typically looks something like "C:\Development\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat". Select that appcompat folder.
    3. Under Projects:, android-support-v7-appcompat should be checked. IMPORTANT: Make sure "Copy projects into workspace" is also checked.
    4. Click finish.
    5. android-support-v7-appcompat project will appear under Package Explorer. Go to File > New > Android Application Project, create a new project and you'll see that appcompat_v7 now is built each time a new project is created.
    6. android-support-v7-appcompat project can be deleted now. After doing this, it'll stop working for the current project and errors will appear. Do this next...
    7. Right click on current project, go to Properties.
    8. Click on Android, then under Library click on Add... and select appcompat_v7 to associate with your current project. Remove android-support-v7-appcompat from the list. Now appcompat_v7 will appear as its own project in your workspace (and it'll probably fix the bin folder), and your current project should hopefully now work.
    0 讨论(0)
  • 2020-12-15 06:13

    One anther thing you ca try is to open the project.properties file of the android-support-v7-appcompat and change the target target=android-21 (latest). Afterwards just do a Project --> Clean... so that the changes take effect.

    0 讨论(0)
  • 2020-12-15 06:20

    For your information, my target SDK is API19 and I am also compiling it with API19

    Use API21 (or greater) for target and compile.

    API 19 does no know the material stuff that is missing.

    To do this with Eclipse, set your own project to target API21 (or greater): open Project Properties and in the Android pane, specify Project Build Tagret as API21 (or greater). When Project Build Tagret of your own project is below 21, errors in the question appear. Clean and re-build your own project when modified its Project Build Tagret.

    0 讨论(0)
  • 2020-12-15 06:23
    1. Update the project.properties file of appcompat v7, which has:target=android-19 to target=android-21

    2. Also update google play services library

    0 讨论(0)
提交回复
热议问题