Получение исключения Nullpointer после обновления до Android design support 22.2.1


Мой проект работал нормально непосредственно перед обновлением до Android design support 22.2.1, после обновления и запуска программы я получаю ошибку ниже. исключение не говорит, какая строка в коде или файле java вызывает ошибку, поэтому не знаю, какой код опубликовать . похоже, это какая-то внутренняя ошибка поддержки дизайна android.

Моя активность расширяется AppCompatActivity и мое тестовое устройство API 15(Android 4.04).

Я использую NavigationView и DrawerLayout в своем коде.

Мой построить.gradle

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.stackoverflow.ranjith.androidprojdel"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.+'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:cardview-v7:22.2.+'
compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.android.support:design:22.2.+'
compile 'joda-time:joda-time:2.8.1'
}

Исключение:

07-19 00:52:49.338: E/AndroidRuntime(15556): FATAL EXCEPTION: main
07-19 00:52:49.338: E/AndroidRuntime(15556): java.lang.NullPointerException
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.support.design.internal.NavigationMenuItemView.setIcon(NavigationMenuItemView.java:113)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.support.design.internal.NavigationMenuItemView.initialize(NavigationMenuItemView.java:72)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.getView(NavigationMenuPresenter.java:305)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.AbsListView.obtainView(AbsListView.java:2045)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.ListView.makeAndAddView(ListView.java:1772)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.ListView.fillDown(ListView.java:672)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.ListView.fillFromTop(ListView.java:732)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.ListView.layoutChildren(ListView.java:1625)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.AbsListView.onLayout(AbsListView.java:1875)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.FrameLayout.onLayout(FrameLayout.java:444)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:931)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.FrameLayout.onLayout(FrameLayout.java:444)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1653)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1511)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1416)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.FrameLayout.onLayout(FrameLayout.java:444)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1653)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1511)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1416)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.widget.FrameLayout.onLayout(FrameLayout.java:444)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.View.layout(View.java:11390)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewGroup.layout(ViewGroup.java:4332)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1490)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2455)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.os.Looper.loop(Looper.java:137)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at android.app.ActivityThread.main(ActivityThread.java:4424)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at java.lang.reflect.Method.invokeNative(Native Method)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at java.lang.reflect.Method.invoke(Method.java:511)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
07-19 00:52:49.338: E/AndroidRuntime(15556):    at dalvik.system.NativeStart.main(Native Method)

Обновить

Когда я откатываюсь к 22.2.0, ошибка исчезает, не знаю, в чем проблема.

2 6

2 ответа:

Проблема связана с xml-меню NavigationView.

Мой выглядит так:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
            android:id="@+id/navigation_subheader"
            android:title="Titulo">
        <menu>
            <item
                    android:id="@+id/navigation_sub_item_1"
                    android:icon="@drawable/abc_btn_radio_material"
                    android:title="sub-1"/>
            <item
                    android:id="@+id/navigation_sub_item_2"
                    android:icon="@drawable/abc_btn_rating_star_on_mtrl_alpha"
                    android:title="sub-2"/>
        </menu>
    </item>
</menu>

Но если я переключаюсь на значок проекта, который можно нарисовать, он фиксируется:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
            android:id="@+id/navigation_subheader"
            android:title="Titulo">
        <menu>
            <item
                    android:id="@+id/navigation_sub_item_1"
              ----> android:icon="@drawable/some_local_drawable"
                    android:title="sub-1"/>
            <item
                    android:id="@+id/navigation_sub_item_2"
              ----> android:icon="@drawable/some_local_drawable"
                    android:title="sub-2"/>
        </menu>
    </item>
</menu>

Конечно, это происходит после обновления до 22.2.1

У меня была та же проблема, и я смог избежать ее с помощью этого кода:

View header = LayoutInflater.from(this).inflate(R.layout.nav_header_main, null);
navigationView.addHeaderView(header);
TextView text = (TextView) header.findViewById(R.id.textView);
texto.setText("HELLO");