Can't call void android.view.View.setElevation(float) on null object in lapism/SearchView

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

I am using library lapism/SearchView (https://github.com/lapism/SearchView) in my project. But i get following runtime exception only on Android 5.0:

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<char> >&, 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<char> >&) 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) 

Please anyone any idea how to fix this problem?

回答1:

To fix this problem you have to update your XML file which contains SearchView and AppBarLayout. Add android:stateListAnimator="@null" to your AppBarLayout as shown below.

 <android.support.design.widget.AppBarLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:stateListAnimator="@null"> 

It shows warning that android:stateListAnimator="@null" attribute stateListAnimator is only used in API level 21. But I've checked source code of the library and it crashes in the SearchBehavior class when it tries to set mAppBarLayout.setStateListAnimator(null);

EDIT

As was mention in comments below this issue is related more to the android components native crash on scrolling in RecyclerView+CollapsingToolbarLayout



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!