我的 android studio 有问题。当我想创建一个项目或我想打开我以前的项目时出现此错误 AAPT2 error: check logs for details
当我检查日志时出现此错误
error: attribute 'com.example.mahdi.servicemanager:headerLayout' not found.
我的项目本来可以正常运行的,但现在报错了,我不明白为什么报错: XML代码:
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
build.gradle 如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mahdi.servicemanager"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
最佳答案
尝试将此 xmlns:app="http://schemas.android.com/apk/res-auto"
添加到您的布局
关于java - 如何修复此错误 AAPT2 错误 : check logs for details?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55782820/