当我初始化项目时,出现“java.lang.NoSuchFieldError:ConstraintLayout_Layout_layoutDescription”

mr *_*oob 5 android kotlin android-studio

好的,我使用默认模板创建一个全新的项目,结果如下: 未能进入

怎么了?这是我的activity_main.xml:

<?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=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

小智 7

只需重建项目即可解决。


mr *_*oob 3

好吧……结果虽然不太令人满意,但确实有效。在设计器中,我转到layoutDiscription字段并输入一些随机数,然后单击锤子图标,它就起作用了!现在即使我创建一个新项目,它仍然有效。感谢你们回答的所有其他问题。