12

私はAndroid SDK 2.2.3を使用しています。私はAndroidのプログラミングに関する本に従っています。パッケージ内の属性 'layout_constraintLeft_toLeftOf'のリソース識別子が見つかりません

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

<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と三つの異なる例を試してみましたし、すべてのケースで、私は同じエラーメッセージが出ます:

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

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

私はエラーを見つけて、エラーを解決するための提案を見つけることができませんでした。

助けてください。

答えて

27

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

はあなたbuild.gradleファイル

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

に依存関係を追加し、Sync nowをクリックします。

関連する問題