4

Ich versuche, die Höhe von AppBarLayout auf 0 (und zurück auf den Standardwert). Es stürzt einige Male (nicht immer) und nur auf API 21 ab (> = 22 etc. funktioniert gut).Android JNI Absturz beim Festlegen von Elevation/StateListAnimator für AppBarLayout

ich ein StateListAnimator bin mit wie in dem unten stehenden Link beschrieben (da es der "offizielle" Weg Höhe einstellen, da Unterstützung-lib 24.0.0):

https://stackoverflow.com/a/37992366/2170109


Meine eigentlichen Methode sieht wie folgt aus:

public void setAppBarElevation(final boolean visible) { 
    if (appBar != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
    appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(this, (visible) ? R.animator.appbar_elevated : R.animator.appbar_not_elevated)); 
    } 
} 

Zusammen mit zwei XML-Dateien (die andere setzt android:valueTo="0"):

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
    <objectAnimator android:propertyName="elevation" 
        android:valueTo="@dimen/default_appbar_elevation" 
        android:valueType="floatType"/> 
    </item> 
</selector> 

ich einige Geräte mit unterschiedlichen Android-Versionen getestet haben (API 19, 21, 23, 24, 25) und es ist nur am 21.

Das Protokoll Absturz zeigt, dass es einige JNI ist -Fehler, wenn die Höheneinstellung (die ich aus den StateListAnimator kommt glaube ich):

--------- beginning of system 
JNI DETECTED ERROR IN APPLICATION: cant call void android.view.View.setElevation(float) on null object 
    in call to CallVoidMethodV 
    from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float) 
"main" prio=5 tid=1 Runnable 
    | group="main" sCount=0 dsCount=0 obj=0x72fc2000 self=0xf421c500 
    | sysTid=20172 nice=0 cgrp=apps sched=0/0 handle=0xf77de160 
    | state=R schedstat=(3803514732 320072004 1563) utm=340 stm=40 core=0 HZ=100 
    | stack=0xff6fb000-0xff6fd000 stackSize=8MB 
    | held mutexes= "mutator lock"(shared held) 
    native: #00 pc 00005b13 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+83) 
    native: #01 pc 00002e92 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+34) 
    native: #02 pc 003c8f68 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+136) 
    native: #03 pc 00391f8d /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+285) 
    native: #04 pc 001006b0 /system/lib/libart.so (art::JniAbort(char const*, char const*)+1024) 
    native: #05 pc 0010125f /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+111) 
    native: #06 pc 001016b2 /system/lib/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+514) 
    native: #07 pc 00112340 /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, char*)+144) 
    native: #08 pc 000776ca /system/lib/libandroid_runtime.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+42) 
    native: #09 pc 00123ecb /system/lib/libandroid_runtime.so (???) 
    native: #10 pc 00089596 /data/dalvik-cache/x86/[email protected]@boot.oat (Java_android_animation_PropertyValuesHolder_nCallFloatMethod__Ljava_lang_Object_2JF+174) 
    at android.animation.PropertyValuesHolder.nCallFloatMethod(Native method) 
    at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38) 
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1296) 
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:952) 
    at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207) 
    at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248) 
    at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659) 
    at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682) 
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 
    at android.view.Choreographer.doCallbacks(Choreographer.java:580) 
    at android.view.Choreographer.doFrame(Choreographer.java:549) 
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5219) 
    at java.lang.reflect.Method.invoke!(Native method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

gibt es eine Möglichkeit zu versteckten e den Schatten der AppBar (und wieder aktivieren) mit der aktuellen Support-Bibliothek (Ich benutze 25.0.0 für jetzt, aber es stürzt auch mit 24.x.x)?

Antwort

0

können Sie versuchen android:stateListAnimator="@null" zu verstecken

Verwandte Themen