无法在lapism / SearchView中的null对象上调用void android.view.View.setElevation(float)

我正在我的项目中使用library lapism / SearchView( https://github.com/lapism/SearchView )。 但我只在Android 5.0上获得了运行时exception:

A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setElevation(float) on null object A/art: art/runtime/check_jni.cc:65] in call to CallVoidMethodV A/art: art/runtime/check_jni.cc:65] from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float) A/art: art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable A/art: art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x757838b0 self=0xb8994958 A/art: art/runtime/check_jni.cc:65] | sysTid=28467 nice=0 cgrp=apps sched=0/0 handle=0xb6f80058 A/art: art/runtime/check_jni.cc:65] | state=R schedstat=( 0 0 0 ) utm=27 stm=10 core=1 HZ=100 A/art: art/runtime/check_jni.cc:65] | stack=0xbe01e000-0xbe020000 stackSize=8MB A/art: art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) A/art: art/runtime/check_jni.cc:65] native: #00 pc 00004828 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23) A/art: art/runtime/check_jni.cc:65] native: #01 pc 00002ec5 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8) A/art: art/runtime/check_jni.cc:65] native: #02 pc 0024437d /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits >&, int, char const*, art::mirror::ArtMethod*)+68) A/art: art/runtime/check_jni.cc:65] native: #03 pc 0022774b /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits >&) const+394) A/art: art/runtime/check_jni.cc:65] native: #04 pc 000af2db /system/lib/libart.so (art::JniAbort(char const*, char const*)+582) A/art: art/runtime/check_jni.cc:65] native: #05 pc 000afa21 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+60) A/art: art/runtime/check_jni.cc:65] native: #06 pc 000b0613 /system/lib/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+402) A/art: art/runtime/check_jni.cc:65] native: #07 pc 000ba087 /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+70) A/art: art/runtime/check_jni.cc:65] native: #08 pc 0006028f /system/lib/libandroid_runtime.so (???) A/art: art/runtime/check_jni.cc:65] native: #09 pc 000721e5 /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_animation_PropertyValuesHolder_nCallFloatMethod__Ljava_lang_Object_2JF+132) A/art: art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder.nCallFloatMethod(Native method) A/art: art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38) A/art: art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1296) A/art: art/runtime/check_jni.cc:65] at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:952) A/art: art/runtime/check_jni.cc:65] at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207) A/art: art/runtime/check_jni.cc:65] at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248) A/art: art/runtime/check_jni.cc:65] at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659) A/art: art/runtime/check_jni.cc:65] at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682) A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:792) A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer.doCallbacks(Choreographer.java:596) A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer.doFrame(Choreographer.java:556) A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:778) A/art: art/runtime/check_jni.cc:65] at android.os.Handler.handleCallback(Handler.java:739) A/art: art/runtime/check_jni.cc:65] at android.os.Handler.dispatchMessage(Handler.java:95) A/art: art/runtime/check_jni.cc:65] at android.os.Looper.loop(Looper.java:155) A/art: art/runtime/check_jni.cc:65] at android.app.ActivityThread.main(ActivityThread.java:5696) A/art: art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke!(Native method) A/art: art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke(Method.java:372) A/art: art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) A/art: art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 

请任何人知道如何解决这个问题?

要解决此问题,您必须更新包含SearchViewAppBarLayout XML文件。 将android:stateListAnimator="@null"AppBarLayout ,如下所示。

   

它显示警告android:stateListAnimator="@null"属性stateListAnimator仅在API级别21中使用。但我检查了库的源代码,当它尝试设置mAppBarLayout.setStateListAnimator(null);时它在SearchBehavior类中崩溃mAppBarLayout.setStateListAnimator(null);

编辑

正如下面的评论中提到的,这个问题更多地与在RecyclerView + CollapsingToolbarLayout中滚动的android组件本机崩溃有关