UnsupportedOperationException:无法解析索引6处的属性:

时间:2017-06-20 04:26:48

标签: android android-layout android-styles

  

引起:java.lang.UnsupportedOperationException:无法解决   索引6处的属性:TypedValue {t = 0x3 / d = 0x141   “res / color / abc_primary_text_material_dark.xml”a = 2 r = 0x7f0d0089}                                                                                    在   android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)                                                                                    在   android.view.ViewGroup $ LayoutParams.setBaseAttributes(ViewGroup.java:6890)                                                                                    在   android.view.ViewGroup $ MarginLayoutParams。(ViewGroup.java:7071)                                                                                    在   android.widget.LinearLayout $的LayoutParams。(LinearLayout.java:1911)                                                                                    在   android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1816)                                                                                    在   android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1815)                                                                                    在android.view.LayoutInflater.parseInclude(LayoutInflater.java:966)                                                                                    在android.view.LayoutInflater.rInflate(LayoutInflater.java:831)                                                                                    在   android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                                    在android.view.LayoutInflater.parseInclude(LayoutInflater.java:971)                                                                                    在android.view.LayoutInflater.rInflate(LayoutInflater.java:831)                                                                                    在   android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                                    在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)                                                                                    在   android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                                    在android.view.LayoutInflater.inflate(LayoutInflater.java:515)                                                                                    在android.view.LayoutInflater.inflate(LayoutInflater.java:423)                                                                                    在android.view.LayoutInflater.inflate(LayoutInflater.java:374)                                                                                    在   android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)                                                                                    在   android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)

我检查了同样异常的其他人。但是没有一个解决方案适合我。

我已经按如下方式设置了值-v21 / styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@color/backgroundColor</item>
        <item name="android:colorPrimary">@color/colorPrimary</item>
        <item name="android:colorAccent">@color/colorAccent</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
    </style>

但是当我在设备上运行时。像上面一样崩溃。我想我正在使用正确的主题。我还在Androidmanifest.xml中设置了使用AppTheme进行应用程序和活动。仍然不起作用。

我的示例代码正在使用上述主题。但示例代码只有一个项目。但是移植到我的工作项目,它有几个库和一些复杂的结构,然后尝试使用任何appcompat v7组件。如果不使用,那么它的好处。如果使用,则崩溃。

有很多项目库和几个渐变。

我添加了一个试图使用appcompt v7组件的项目gradle。

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 21
        versionName rootProject.ext.versionName
        versionCode rootProject.ext.versionCode
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    compile project(':xxxxLibrary')
    compile project(':xxxx2Library')
    compile project(':xxxxx3Library')
    compile 'com.google.firebase:firebase-messaging:9.0.2'
    compile 'com.google.android.gms:play-services-auth:9.0.2'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
}

有什么建议吗?

顺便说一句,我无法将目标sdk版本更新到最新版本。由于运行时权限。我们的ndk库有重定位问题,我无权解决。所以目前targetsdk是21。

三个布局文件。  1. entry_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/entry_drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <include layout="@layout/entry_view_pager_layout" />

        <!-- The navigation drawer-->
        <android.support.design.widget.NavigationView
            android:id="@+id/entry_navigation_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:menu="@menu/drawer_menu" />

    </android.support.v4.widget.DrawerLayout>


</RelativeLayout>
  1. entry_view_pager_layout.xml

    <include layout="@layout/app_toolbar"/>
    

  2. app_toolbar.xml

    <android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/app_toolbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/actionBarSize"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
    
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:id="@+id/app_toolbar_title"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center_vertical"/>
    </FrameLayout>
    

  3. 最后我删除了其他视图寻呼机和标签布局,只保留工具栏来跟踪问题。

0 个答案:

没有答案