Android 未找到属性';布局(u constraintLeft)u toLeftOf';打包
我正在使用Android SDK 2.2.3。我正在看一本关于Android编程的书 代码是:Android 未找到属性';布局(u constraintLeft)u toLeftOf';打包,android,android-layout,android-studio,android-constraintlayout,Android,Android Layout,Android Studio,Android Constraintlayout,我正在使用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.and
<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>
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'
}
我必须做些什么来解决错误
我已经在谷歌上搜索了错误,但没有找到解决错误的建议
请帮忙
ConstraintLayout
不是AppCompat的一部分。这是一个独立的图书馆
在build.gradle
文件中添加依赖项
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
然后单击
Sync now
我也遇到了同样的问题,将这一行添加到build.gradle(模块应用程序)
解决了它
compile'com.android.support.constraint:constraint layout:1.1.0-beta3'
配置“compile”已过时,已被“implementation”和“api”取代。因此,请使用实现'com.android.support.constraint:constraint布局:1.1.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'