#StackBounty: #android #android-studio #preview Android Studio preview doesn't show when a floating action button is in the layout

Bounty: 50

Exactly as the title suggests when I have a floating action button anywhere in my layout in any xml file the preview stops working, I can literally comment it out and it will instantly redraw perfectly. any ideas?

I have tried resetting multiple times syncing, invalidating caches etc.
When i reset the view is rendered fine but only for pages open any i open after will not render and navigating back to the previously rendered layout breaks it The only thing I can think of is I use clans floating action button in my project, but it’s the Google one that breaks my preview.

Also using AndroidX

here is an example of an xml that will not render

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".settings.PdfSettingsActivity">

<ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintEnd_toEndOf="parent"
  app:layout_constraintTop_toTopOf="parent"
  android:scaleType="centerCrop"
  android:layout_margin="@dimen/activity_vertical_margin_16dp"
  android:elevation="@dimen/activity_horizontal_margin_4dp"
  android:id="@+id/pdf_renderer"/>




<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/share"
    android:layout_margin="@dimen/activity_vertical_margin_16dp"
    android:src="@drawable/ic_share_white_24dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

if i comment out the floating action button the view immediately renders

com.google.android.material.floatingactionbutton.FloatingActionButton

Android Studio 3.4.1 Build #AI-183.6156.11.34.5522156, built on May 1,
2019 JRE: 1.8.0_152-release-1343-b01 x86_64 JVM: OpenJDK 64-Bit Server
VM by JetBrains s.r.o macOS 10.14.3

EDIT

Just playing around with it now and I manage to make it throw an an error:

java.lang.IllegalArgumentException: java.lang.ClassCastException@54291cbb
at sun.reflect.GeneratedMethodAccessor971.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
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)
at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1339)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1471)
at android.animation.ValueAnimator.pulseAnimationFrame(ValueAnimator.java:1490)
at android.animation.AnimatorSet.pulseFrame(AnimatorSet.java:1163)
at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1146)
at android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1046)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:947)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer_Delegate.doFrame(Choreographer_Delegate.java:66)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:563)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:425)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:120)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:151)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:133)
at com.android.tools.idea.rendering.RenderTask.lambda$null$8(RenderTask.java:755)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.