J'utilise la bibliothèque lapism/SearchView ( https://github.com/lapism/SearchView ) dans mon projet. Mais je reçois une exception d’exécution seulement sur 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@[email protected] (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)
S'il vous plaît quelqu'un a une idée comment résoudre ce problème?
Pour résoudre ce problème, vous devez mettre à jour votre fichier XML qui contient SearchView
et AppBarLayout
. Ajoutez Android:stateListAnimator="@null"
à votre AppBarLayout
comme indiqué ci-dessous.
<Android.support.design.widget.AppBarLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:stateListAnimator="@null">
Il indique que Android:stateListAnimator="@null"
attribut stateListAnimator est uniquement utilisé dans l'API de niveau 21. Mais j'ai vérifié le code source de la bibliothèque et il se bloque dans la classe SearchBehavior
lorsqu'il tente de définir mAppBarLayout.setStateListAnimator(null);
MODIFIER
Comme mentionné dans les commentaires ci-dessous, ce problème est davantage lié aux composants Android crash natif lors du défilement dans RecyclerView + CollapsingToolbarLayout
L'attribut AppCarLayout app:elevation="..dp"
permet de résoudre ce problème