Android的XML:RuntimeException的:无法在索引6化解属性 [英] Android XML: RuntimeException: Failed to resolve attribute at index 6

查看:815
本文介绍了Android的XML:RuntimeException的:无法在索引6化解属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好亲爱stackoverflower,

Hello dear stackoverflower,

在我的项目,我使用了新的机器人设计库。
问题是,有一个运行时异常它说(我试着去创造一个FloatingButton):

In my project, i am using the new "android design library". The problem is, that there is a runtime exception which says(Im trying to create a FloatingButton):

 java.lang.RuntimeException: Failed to resolve attribute at index 6
        at android.content.res.TypedArray.getColorStateList(TypedArray.java:426)
        at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:91)
        at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:79)
        at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:75)

我能弄清楚,它的属性不能被解析:

I was able to figure out, which the attribute cannot be resolved :

<style name="Widget.Design.FloatingActionButton" parent="android:Widget">
    <item name="android:background">@drawable/fab_background</item>
    <item name="backgroundTint">?attr/colorAccent</item>  **!! this one is missing !!**
    <item name="fabSize">normal</item>
    <item name="elevation">@dimen/fab_elevation</item>
    <item name="pressedTranslationZ">@dimen/fab_translation_z_pressed</item>
    <item name="rippleColor">?attr/colorControlHighlight</item>
    <item name="borderWidth">@dimen/fab_border_width</item>
</style>

这是位于RES /价值/风格/ styles.xml在Android的设计库

This is located in res/values/styles/styles.xml in the android-design-library

我已经在<读href=\"http://stackoverflow.com/questions/27791290/no-resource-identifier-found-for-attribute-backgroundtint-in-package-android\">this发布该API拉特应双21+。但随着设计库支持API 7+,这不应该是一个问题,其实。

i have read in this post that the API lvl should bis 21+. But as the design library supports API 7+, this should not be a problem actually.

另外,值得一提的是我还没有包括设计库这样的gradle这个依赖关系:

It is also worth to mention that i have not included the design library as a gradle-dependency like this:

 compile 'com.android.support:design:22.2.0'

我手动添加库项目,因为詹金斯服务器没有上网。
我已经支持-V4库更新到21.2.0
还有应用程序兼容性支持-V7包括和更新。

I am adding the library manually to the project because the Jenkins server has no Internet access. I have updated the support-v4 library to 21.2.0 also the appcompat support-v7 is included and updated.

下面是Android的设计库文件的gradle:

Here is the android-design-library gradle file:

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    minSdkVersion 17
    targetSdkVersion 21
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

这将是巨大的,如果有人能帮助我。

It would be great if someone can help me.

推荐答案

遇到了这个问题,我自己。这是因为我的应用程序不使用应用程序兼容性呢,还只是常规的支持 FragmentActivity 。这意味着 FloatingActionButton 是找两个主题的属性和它无法找到他们。

Ran into this problem myself. It's because my app isn't using AppCompat yet, still just the regular support FragmentActivity. This means that FloatingActionButton was looking for two theme attributes and it couldn't find them.

具体在这些缺少的属性将使得它为我工作,而不需要开始使用应用程序兼容性。

Specifically adding in these missing attributes made it work for me without the need to start using AppCompat.

<LinearLayout
    ...
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    .../>

    <android.support.design.widget.FloatingActionButton
        ...
        app:backgroundTint="@color/{some color statelist}"
        app:rippleColor="@color/{some color statelist}"
        ... />

</LinearLayout>

这篇关于Android的XML:RuntimeException的:无法在索引6化解属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆