错误:(8、35)cvc-elt.1.a:找不到元素'android.support.constraint.ConstraintLayout'

时间:2018-08-26 07:40:42

标签: android

我对Android应用程序开发完全陌生,刚刚开始观看一场视频培训,并安装了Andriod Studio。我已经创建了一个打印“ hello world”的程序,但是它给出的错误很少,我不知道,因为培训是非常基础的,并且没有错误信息。

我的代码是:(基本上这是我开始新项目时自动生成的代码)

<?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: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" />

</android.support.constraint.ConstraintLayout>

它给出了以下错误:

Error:(8, 35) cvc-elt.1.a: Cannot find the declaration of element 'android.support.constraint.ConstraintLayout'.
Error:(1, 56) s4s-elt-schema-ns: The namespace of element 'x' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Error:(1, 56) s4s-elt-invalid: Element 'x' is not a valid element in a schema document.
Error:(1, 56) schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

1 个答案:

答案 0 :(得分:1)

您应将此添加到build.gradle(应用程序)

implementation 'com.android.support.constraint:constraint-layout:1.0.2' 

或从here

下载约束布局