Android 无法在pre L设备上充气工具栏

Android 无法在pre L设备上充气工具栏,android,Android,我试图在pre-L设备上充气工具栏。我使用了一个扩展了theme.AppCompat.Light的主题,这样像:?attr/actionBarSize这样的属性就可以工作了 但是,我得到以下错误: Error inflating class android.support.v7.widget.Toolbar Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_b

我试图在pre-L设备上充气
工具栏
。我使用了一个扩展了
theme.AppCompat.Light
的主题,这样像:
?attr/actionBarSize
这样的属性就可以工作了

但是,我得到以下错误:

 Error inflating class android.support.v7.widget.Toolbar
 Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
我的
工具栏
来自
XML
是这样的:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/material_drawer_primary"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/****"
        app:popupTheme="@style/****"
        app:contentInsetStart="72dp"/>

我的主题是:

<style name="****" parent="Theme.AppCompat.Light">
        <!-- ...and here we setting appcompat’s color theming attrs -->
        <item name="colorPrimary">@color/material_drawer_primary</item>
        <item name="colorPrimaryDark">@color/material_drawer_primary_dark</item>
        <item name="colorAccent">@color/material_drawer_accent</item>

        <!-- MaterialDrawer specific values -->
        <item name="material_drawer_background">@color/material_drawer_background</item>
        <item name="material_drawer_primary_text">@color/material_drawer_primary_text</item>
        <item name="material_drawer_primary_icon">@color/material_drawer_primary_icon</item>
        <item name="material_drawer_secondary_text">@color/material_drawer_secondary_text</item>
        <item name="material_drawer_hint_text">@color/material_drawer_hint_text</item>
        <item name="material_drawer_divider">@color/material_drawer_divider</item>
        <item name="material_drawer_selected">@color/material_drawer_selected</item>
        <item name="material_drawer_selected_text">@color/material_drawer_selected_text</item>
        <item name="material_drawer_header_selection_text">@color/material_drawer_header_selection_text</item>
    </style>

@颜色/材质\u抽屉\u主
@颜色/材质\u抽屉\u主\u深色
@颜色/材质\u抽屉\u口音
@颜色/材质\u抽屉\u背景
@颜色/材质\u抽屉\u主\u文本
@颜色/材质\u抽屉\u主图标
@颜色/材料\u抽屉\u辅助\u文本
@颜色/材料\u抽屉\u提示\u文本
@颜色/材料\u抽屉\u分隔器
@颜色/材料\u抽屉\u已选择
@颜色/材料\u抽屉\u选定\u文本
@颜色/材料\u抽屉\u标题\u选择\u文本
有办法解决这个问题吗?谢谢大家!

编辑1:我还尝试了
Theme.AppCompat.Light.NoActionBar
找到了答案:

似乎更新以支持库23.2.0会导致此问题

对于那些不想透露更多细节的人,您只需执行以下操作:

如果您有
Gradle
2.0版或更高版本:

android {
  defaultConfig {
    vectorDrawables.useSupportLibrary = true
  }
}
或者,如果您的版本为1.5或更低版本:

android {
  defaultConfig {
    // Stops the Gradle plugin’s automatic rasterization of vectors
    generatedDensities = []
  }
  // Flag to tell aapt to keep the attribute ids around
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

对我来说,这解决了问题

包括必要代码,以防链接被删除/删除

取决于您使用的渐变版本。对于新的2.0 Gradle插件,它是一个单行程序:

// Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }
对于Gradle版本1.5(对于较旧的Gradle版本没有此类修复):

在应用程序的build.gradle文件中放置这些选项后,即使在较旧的设备上,一切都将恢复正常。另外,不要忘记将Gradle插件升级到1.5.0或更高版本,因为旧版本不受支持

// Gradle Plugin 1.5  
 android {  
   defaultConfig {  
     generatedDensities = []  
  }  

  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
 }