ConstraintLayout 在蓝图模式之外无法正确呈现

ConstraintLayout does not render correctly outside blueprint mode

我今天开始使用 Android Studio 2.2 和 ConstraintLayout,但我在渲染方面遇到了一些问题。使用蓝图模式时,一切看起来都很好。使用设计模式时,对象卡在左上角,全部混在一起。

Android Studio 警告: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:517)
    at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:433)
    at android.support.constraint.ConstraintLayout.onMeasure_Original(ConstraintLayout.java:728)
    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)

依赖关系:

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'

这是 Android Studio 中无法解决的错误还是有什么可以解决的? SDK已更新。

编辑

XML 文件:

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.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:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:src="@drawable/about"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView6"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="16dp" />

    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView33"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/imageView6"
        android:layout_marginLeft="16dp" />

    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView34"
        app:layout_constraintRight_toRightOf="@+id/textView33"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/textView33" />
</android.support.constraint.ConstraintLayout>

如此处所述 Constraint Layout Alpha8 release notes

注意:由于 API 更改,您可能需要在升级到 alpha 8 后重新启动 Android Studio 2.2 才能进行布局预览。

所以从菜单栏中,select file 然后选择 invalidate caches / restart

更新后我遇到了这个问题

implementation 'androidx.constraintlayout:constraintlayout:1.1.3

implementation 'androidx.constraintlayout:constraintlayout:2.0.2'

降级回 1.1.3 解决问题