我的应用程序在最新的API上正常运行但是当我尝试在Kit Kat API 19上运行时,它开始崩溃并出现以下异常
android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
在xml文件的第17行,我有
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- app:itemIconTint="@color/colorAccent" -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:menu="@menu/activity_home_drawer" />
例外:
06-09 17:25:53.533: E/AndroidRuntime(3356): FATAL EXCEPTION: main
06-09 17:25:53.533: E/AndroidRuntime(3356): Process: com.app.myapp, PID: 3356
06-09 17:25:53.533: E/AndroidRuntime(3356): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.myapp/com.app.myapp.HomeActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.os.Handler.dispatchMessage(Handler.java:102)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.os.Looper.loop(Looper.java:136)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread.main(ActivityThread.java:5017)
06-09 17:25:53.533: E/AndroidRuntime(3356): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 17:25:53.533: E/AndroidRuntime(3356): at java.lang.reflect.Method.invoke(Method.java:515)
06-09 17:25:53.533: E/AndroidRuntime(3356): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-09 17:25:53.533: E/AndroidRuntime(3356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-09 17:25:53.533: E/AndroidRuntime(3356): at dalvik.system.NativeStart.main(Native Method)
06-09 17:25:53.533: E/AndroidRuntime(3356): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.createView(LayoutInflater.java:621)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-09 17:25:53.533: E/AndroidRuntime(3356): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.Activity.setContentView(Activity.java:1929)
06-09 17:25:53.533: E/AndroidRuntime(3356): at com.app.myapp.HomeActivity.onCreate(HomeActivity.java:66)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.Activity.performCreate(Activity.java:5231)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-09 17:25:53.533: E/AndroidRuntime(3356): ... 11 more
06-09 17:25:53.533: E/AndroidRuntime(3356): Caused by: java.lang.reflect.InvocationTargetException
06-09 17:25:53.533: E/AndroidRuntime(3356): at java.lang.reflect.Constructor.constructNative(Native Method)
06-09 17:25:53.533: E/AndroidRuntime(3356): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.view.LayoutInflater.createView(LayoutInflater.java:595)
06-09 17:25:53.533: E/AndroidRuntime(3356): ... 22 more
06-09 17:25:53.533: E/AndroidRuntime(3356): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0200cc
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.content.res.Resources.getValue(Resources.java:1123)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:321)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:192)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:421)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.prepareMenuItems(NavigationMenuPresenter.java:495)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.update(NavigationMenuPresenter.java:436)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.internal.NavigationMenuPresenter.updateMenuView(NavigationMenuPresenter.java:112)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.widget.NavigationView.inflateMenu(NavigationView.java:245)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.widget.NavigationView.<init>(NavigationView.java:169)
06-09 17:25:53.533: E/AndroidRuntime(3356): at android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
06-09 17:25:53.533: E/AndroidRuntime(3356): ... 25 more