web-dev-qa-db-ja.com

パッケージ内の属性「layout_constraintLeft_toLeftOf」のリソース識別子が見つかりません

Android SDK 2.2.3を使用しています。 Androidのプログラミングに関する本をフォローしています。

コードは次のとおりです。

<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で3つの異なる例を試しましたが、すべての場合に同じエラーメッセージが表示されます。

Error:(13) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'eu.a123sandberg.webview'

Build.gradleファイルには次が含まれます。

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'
}

エラーを解決するにはどうすればよいですか?

エラーをグーグルで検索しましたが、エラーを解決する提案を見つけることができませんでした。

助けてください。

35
Jorgen Sandberg

ConstraintLayoutはAppCompatの一部ではありません。それはスタンドアロンのライブラリです。

build.gradleファイルに依存関係を追加します

implementation 'com.Android.support.constraint:constraint-layout:1.1.3' 

Sync nowをクリックします。

70
Akash Patel

私は同じ問題を抱えていましたが、build.gradle(module app)にこの行を追加すると解決しました。 'com.Android.support.constraint:constraint-layout:1.1.0-beta3'をコンパイルします