Android支持库v7:检索项目的父项时出错(Android Support Library v7: Error retrieving parent for item)
我正在尝试构建Android支持库v7示例。
为此,我通过Eclipse创建了一个示例项目 - >新的Android示例项目,并将android-support-v7- *项目作为“从现有代码的Android项目”添加到Eclipse中,并使示例项目引用它们。
但是我在android-support-v7-mediarouter/res/values/styles.xml收到以下错误:
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'. (第18行)
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'. (第28行)
我可以如何解决这些错误并构建示例项目?
I am trying to build the Android Support Library v7 samples.
For that, I created an sampleproject through Eclipse -> New Android Sample Project and added the android-support-v7-* projects as "Android Project From Existing Code" to Eclipse, and made the sample project reference them.
But I am getting the following errors in android-support-v7-mediarouter/res/values/styles.xml:
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'. (line 18)
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'. (line 28)
What can I do to fix these errors and build the sample project?
原文:https://stackoverflow.com/questions/18964902
更新时间:2019-11-20 04:53
最满意答案
您必须使android-support-v7-mediarouter项目“感知”android-support-v7-appcompat项目作为引用库。
右键单击android-support-v7-mediarouter项目,选择“ 属性”
选择Android
在底部的库部分,单击添加...。
在对话框中选择android-support-v7-appcompat 。
单击应用 。
单击确定 。
在android-support-v7-mediarouter项目上做一个干净的构建。
You must make the android-support-v7-mediarouter project "aware" of the android-support-v7-appcompat project as a referenced library.
Right click android-support-v7-mediarouter project, select Properties
Select Android
In the Library section at the bottom, click Add....
Select android-support-v7-appcompat in the dialog.
Click Apply.
Click OK.
Do a clean build on the android-support-v7-mediarouter project.
2014-06-27
相关问答
事实证明,我必须制定目标并将版本编译为L,这意味着我无法在较旧的SDK上运行我的应用程序。 如果您希望您的应用在SDK 19中运行并且更低,则必须将您的编译和目标版本设置为19,并将最小SDK设置为您需要的任何版本。 接下来,您必须将导入调整为与您选择编译的SDK兼容的版本。 例如,如果你想在sdk 19上使用v7支持库,你必须像这样导入它:compile compile'com.android.support:appcompat-v7:20.+' Turns out that I had to
...
首先,您现在应该知道android.support.v4.app.ActionBarDrawerToggle已被弃用。 您必须用android.support.v7.app.ActionBarDrawerToggle替换。 这是我的例子,我使用新的Toolbar替换ActionBar 。 MainActivity.java public class MainActivity extends ActionBarActivity {
@Override
protected void o
...
您必须使android-support-v7-mediarouter项目“感知”android-support-v7-appcompat项目作为引用库。 右键单击android-support-v7-mediarouter项目,选择“ 属性” 选择Android 在底部的库部分,单击添加...。 在对话框中选择android-support-v7-appcompat 。 单击应用 。 单击确定 。 在android-support-v7-mediarouter项目上做一个干净的构建。 You mu
...
由于属性是在库(支持v7)中定义的,因此您可以将其用作用户定义的属性:即不使用android: prefix: android:background="?attr/selectableItemBackground"
你看到的错误是指出?android:attr/selectableItemBackground可用于API版本= = 11。 Since the attribute is defined in a library (support v7), you would use it as a
...
您正在使用compileSdkVersion 23因此您需要使用api 23的支持库 compile 'com.android.support:recyclerview-v7:25.0.1'
将RecyclerView降级到23或将compileSdkVersion升级到25 you are using compileSdkVersion 23 so you need to use the support libs of api 23 compile 'com.android.support:r
...
发现CustomActivity必须是ActionBarActivity的子代。 我改变了这个错误消失了。 Happens that it is necessary for the CustomActivity to be child of ActionBarActivity. I changed this and the error disappeared.
在了解发布多个变体后,我自己解决了这个问题。 简而言之:1.添加 android { ... // Tells Gradle to build all variants of the library. Note that this // may increase build times because Gradle must build multiple AARs, // instead of only one. publishNonDefault true } 去图书馆。 2.增加 androi
...
我在没有代码的情况下在黑暗中采取了一些刺,但我相信你没有正确引用父。 尝试; @android:style/Theme....
要么 @android:style/Widget....
等等 I'm taking a bit of a stab in the dark here without code but I believe you are not referencing the parent correctly. Try; @android:style/Theme....
or @a
...
你需要用api 23编译。 更改build.gradle这一行: compileSdkVersion 23
既然你正在使用 compile 'com.google.android.gms:play-services:+'
您正在使用与支持库v23相关的最新版本8.4.0 。 这是因为gradle使用v23而不是v22。 一般来说, 避免在build.gradle文件中使用+是一个很好的做法,因为这样你就不知道你使用的是哪个版本的依赖项,并且将来也无法重现你的代码。 也不要使用不同版本的支持
...
您的values.xml中可能存在错误,但它可能位于另一个xml文件中。 检查所有xml文件。 希望这可以帮助。 Probably, theres an error in your values.xml, but it could be on another xml file. Check all your xml files. Hope this helps.