java - 如何修复此错误 AAPT2 错误 : check logs for details?

标签 java android xml gradle build.gradle

我的 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/

相关文章:

java - 类中的全局数组根据传递参数问题初始化大小

android - 将 firebase 用户与应用内订阅相关联

android - Styleable无法解析

android - 在我的应用程序 APK 中包含早期版本的 android 框架 JAR?

android - Chromecast:管理来自发送者 Android 的接收者中的停止事件(不是暂停)

c# - 如何从 XmlNodeList 中删除 XmlNode

android - 布局验证不同于加载程序 android Studio

java - 一次进行 1、2 或 3 步到第 n 步的组合数‽

java - 如何降低这部分代码的复杂性?

java - 在应用程序启动期间打印所有 REST 服务 URL