ConstraintLayout 设计器渲染异常

ConstraintLayout designer rendering exception

ConstraintLayout 升级到 alpha9 后,我在设计模式中遇到 onMeasure() 错误渲染问题:

详情(例外):

java.lang.NoSuchMethodError: android.support.constraint.solver.widgets.ConstraintWidget.immediateConnect(Landroid/support/constraint/solver/widgets/ConstraintAnchor$Type;Landroid/support/constraint/solver/widgets/ConstraintWidget;Landroid/support/constraint/solver/widgets/ConstraintAnchor$Type;II)V at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:555) at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:468) at android.support.constraint.ConstraintLayout.onMeasure_Original(ConstraintLayout.java:770) at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java) at android.view.View.measure(View.java:19731) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:19731) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:19731) at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:545) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:342) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389) at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:548) at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:533) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533) at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:659) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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)

如果我将 build.gradle 中的依赖项从 com.android.support.constraint:constraint-layout:1.0.0-alpha9 更改回 com.android.support.constraint:constraint-layout:1.0.0-alpha8,一切都会再次正常。

有什么建议吗? alpha9 版本损坏?

如发行说明中所述,根据您的平台,您可能必须重新启动工作室 and/or 安装 alpha 9 后使缓存无效 :-/

文件 -> 无效 cache/restart。这将解决问题。