Android Layout Preview Editor - Layout not visible: java.lang.IllegalArgumentException: object is not an instance of declaring class
Asked Answered
A

1

7

My Android Studio Layout Editor is not working as expected. The preview always disappers and turns into a completely white screen or freezes (i cannot select any element and changes i make to the xml file are not visible) after i make a change to the layout. This happens in any layout file. I works again after invalidating chaches and restarting but after i make another change i have the same problem again. Performing a clean build doens't help either.

The layout editor shows the following exception:

java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
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.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)

However i cannot comprehend what is going on. I am not even sure if this error is the cause of my problem. Maybe you can help.

Note: I am using the Theme.MaterialComponents.Light.NoActionBar theme

Abridgment answered 22/5, 2019 at 18:34 Comment(9)
Is that the full error?Maupassant
I assume, this is all the layout editor shows me when i click on "details"Abridgment
Do you know what part of your code is triggering this error?Maupassant
As it turns out adding either a <button> (which is replaced by MaterialButton) or a <com.google.android.material.appbar.AppBarLayout> causes the issueAbridgment
Ok, this sounds like an android bug in that case. You may want to open a bug report.Maupassant
I am using 'com.google.android.material:material:1.1.0-alpha06'. Since this is an alpha, it is likely that it is a bug. I will file a bug report shortly. Thank you for your help.Abridgment
any bugtracker link ? i have this freaking issue for last 3 month :/Convexoconcave
@Convexoconcave I refrained from filing a bug report because I'm inexperienced in doing that and downgrading fixed the issue. You can do it though.Abridgment
@Abridgment after many hours I've figure it out that it's not Android Studio Problem , it's Gradle Plugin problem , i have revert the gradle plugin and my gradle to the previous version and now everything works fine !Convexoconcave
G
0

Update your dependencies to the alpha09 and it is fixe:

implementation "com.google.android.material:material:1.1.0-alpha09"          // Material Components
Guardsman answered 18/8, 2019 at 12:3 Comment(1)
Tried the alpha09 change, but didn't work across multiple restarts...Breadbasket

© 2022 - 2024 — McMap. All rights reserved.