错误膨胀类android.support.design.widget.NavigationView,在三星设备上获取错误,

时间:2016-06-10 14:25:15

标签: android samsung-mobile android-design-library androiddesignsupport

应用程序在其他设备上运行正常,只有三星设备(Android 4.2和4.4 kitkat),Galaxygrand,Core Prime等。

我正在使用设计支持库中的Appcompact NavigationView。

dependencies {
    compile 'com.flurry.android:analytics:6.2.0'

    compile project.COMPILE_APPCOMPACT_VERSION
    // Support Libraries
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
//    compile 'com.android.support:gridlayout-v7:23.0.1'
//    compile 'com.android.support:leanback-v17:23.0.1'
    compile 'com.android.support:mediarouter-v7:23.0.1'
    compile 'com.android.support:palette-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:support-annotations:23.0.1'
//    compile 'com.android.support:support-v13:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'



 <android.support.design.widget.NavigationView
        android:id="@+id/main_nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:itemTextColor="@drawable/drawer_item"
        app:menu="@menu/activity_main_drawer"
        app:theme="@style/NavigationDrawerStyle" />

错误是

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manish.indiancallerdetail/com.manish.indiancallerdetail.ui.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2464)
    at android.app.ActivityThread.access$900(ActivityThread.java:172)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5653)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView
    at android.view.LayoutInflater.createView(LayoutInflater.java:626)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:255)
    at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:109)
    at com.manish.indiancallerdetail.ui.common.BaseAppCompActivity.setContentView(SourceFile:85)
    at com.manish.indiancallerdetail.ui.MainActivity.onCreate(SourceFile:85)
    at android.app.Activity.performCreate(Activity.java:5541)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2368)
    ... 11 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at android.view.LayoutInflater.createView(LayoutInflater.java:600)
    ... 23 more
Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x5/d=0x1001 a=2 r=0x105002b}
    at android.content.res.Resources.loadColorStateList(Resources.java:3532)
    at android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
    at android.support.design.widget.NavigationView.<init>(SourceFile:119)
    at android.support.design.widget.NavigationView.<init>(SourceFile:92)
    ... 26 more

```

1 个答案:

答案 0 :(得分:0)

您应该更新支持库。

最新com.android.support版本为23.4.0,请参阅here

    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
//    compile 'com.android.support:gridlayout-v7:23.4.0'
//    compile 'com.android.support:leanback-v17:23.4.0'
    compile 'com.android.support:mediarouter-v7:23.4.0'
    compile 'com.android.support:palette-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:support-annotations:23.4.0'
//    compile 'com.android.support:support-v13:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'