首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在包中找不到属性'layout_constraintLeft_toLeftOf‘的资源标识符

在包中找不到属性'layout_constraintLeft_toLeftOf‘的资源标识符
EN

Stack Overflow用户
提问于 2017-02-24 20:56:17
回答 2查看 37K关注 0票数 41

我使用的是Android SDK 2.2.3。我正在阅读一本关于Android编程的书。

代码是:

代码语言:javascript
复制
<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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="eu.a123sandberg.webview.MainActivity"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="81dp">

    <WebView
        android:layout_width="384dp"
        android:layout_height="511dp"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp"
        app:layout_constraintLeft_toLeftOf="@+id/activity_main"
        tools:layout_constraintLeft_creator="0"
        app:layout_constraintTop_toTopOf="@+id/activity_main"
        tools:layout_constraintTop_creator="0"
        app:layout_constraintRight_toRightOf="@+id/activity_main"
        tools:layout_constraintRight_creator="0"
        app:layout_constraintBottom_toBottomOf="@+id/activity_main"
        tools:layout_constraintBottom_creator="0"
        />

</android.support.constraint.ConstraintLayout>

我已经使用android.support.constraint.ConstraintLayout尝试了三个不同的示例,在所有情况下,我是否都收到相同的错误消息:

代码语言:javascript
复制
Error:(13) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'eu.a123sandberg.webview'

build.gradle文件包含:

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "eu.a123sandberg.webview"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
                                                                                  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-                   android.txt'), 'proguard-rules.pro'
        }
     }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-            core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    testCompile 'junit:junit:4.12'
}

我必须怎么做才能解决这个错误?

我已经在谷歌上搜索了错误,但找不到解决该错误的建议。

请帮帮忙。

EN

回答 2

Stack Overflow用户

发布于 2017-02-24 21:08:55

ConstraintLayout不是AppCompat的一部分。它是一个独立的库。

build.gradle文件中添加依赖项

代码语言:javascript
复制
implementation 'com.android.support.constraint:constraint-layout:1.1.3' 

然后单击Sync now

票数 82
EN

Stack Overflow用户

发布于 2018-06-06 22:08:52

我也遇到了同样的问题,将这一行添加到build.gradle(module app)就解决了这个问题。

compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42439241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档