Material 浮动操作按钮导致错误和崩溃 xml

Material Floating Action Button causing error and crashing xml

我迁移到 androidx,我的依赖项是:

implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'com.google.android.material:material:1.1.0-alpha06'

我用了 FloatingActionButton :

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_margin="15dp"
    app:backgroundTint="@color/colorAccent"
    app:srcCompat="@drawable/ic_add_32dp"/>

但是当我输入 FloatingActionButton 时,XML 崩溃(渲染问题)。即使我使用以下内容:

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
   />

不过这个错误只出现在XML,不影响程序的执行,对我来说也没有显示design modeinvalidate Cache and Restart的问题是它暂时解决了问题,但它再次发生。

渲染问题是:

java.lang.IllegalArgumentException: java.lang.ClassCastException@7e11486d   at java.lang.reflect.Method.invoke(Method.java:498)   at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)   at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)   at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java:-1)   at android.animation.PropertyValuesHolder.access0(PropertyValuesHolder.java:38)   at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)   at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)   at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)   at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)   at android.animation.ValueAnimator.start(ValueAnimator.java:1069)   at android.animation.ValueAnimator.start(ValueAnimator.java:1088)   at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)   at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1081)   at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)   at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227)   at android.animation.AnimatorSet.start(AnimatorSet.java:729)   at android.animation.AnimatorSet.start(AnimatorSet.java:684)   at android.animation.StateListAnimator.start(StateListAnimator.java:188)   at android.animation.StateListAnimator.setState(StateListAnimator.java:181)   at android.view.View.drawableStateChanged(View.java:21105)   at android.widget.ImageView.drawableStateChanged(ImageView.java:1294)   at com.google.android.material.floatingactionbutton.FloatingActionButton.drawableStateChanged   ... (FloatingActionButton.java:805)   at android.view.View.refreshDrawableState(View.java:21160)   at android.view.View.dispatchAttachedToWindow(View.java:18379)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)   at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)

这是一个已知错误,已在 Studio 3.5beta2! 中修复 这个问题似乎是高程属性

有关详细信息,请参阅: