首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复Android中的"Android资源链接失败“错误?

如何修复Android中的"Android资源链接失败“错误?
EN

Stack Overflow用户
提问于 2021-02-28 19:37:51
回答 10查看 46.9K关注 0票数 20

我刚开始学习和使用"Android“软件和编辑一个项目。想办法解决这个问题花了很长时间。我只是修正了许多错误,现在我知道很多关于错误的事情,但是有一件事发生在我身上,这让我发疯了!我不能纠正这个错误,也不知道这是怎么回事。这是错误:

代码语言:javascript
运行
复制
> Task :app:processReleaseResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/dialogCornerRadius' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.\n    ","tool":"AAPT"}

Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\****\.gradle\caches\transforms-2\files-2.1\b635fd2d4b36b21da676271add72c19b\material-1.4.0-alpha01\res\values\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.

在错误文本中寻址的文件不在我的项目文件夹中,并且确定它是gradle缓存的文件夹!试图清除缓存,重建项目,从文件中删除代码行等,什么都不工作!希望有人能帮我这个忙。

我的"build.gradle“文件代码是:

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'

android {

    compileSdkVersion 21
    buildToolsVersion '29.0.3'

    defaultConfig {
        applicationId "com.troup.platform"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 78
        versionName '5.7'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

    dexOptions {

        jumboMode true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    productFlavors {
    }
    ndkVersion '22.0.7026061'
}

dependencies {
    implementation  fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.chrisbanes.photoview:library:1.2.4'
    implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.squareup.okhttp:okhttp:2.7.5'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.mediarouter:mediarouter:1.2.2'
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-core:18.0.2'
    implementation 'com.google.firebase:firebase-ads:19.7.0'
    implementation 'com.google.firebase:firebase-messaging:21.0.1'
    implementation 'com.google.firebase:firebase-analytics:18.0.2'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.7.0'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.android.billingclient:billing:3.0.2'
    implementation 'com.google.android.exoplayer:exoplayer:2.7.2'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.exifinterface:exifinterface:1.3.2'
    implementation "com.google.android.material:material:1.4.0-alpha01"

    implementation  files('libs/YouTubeAndroidPlayerApi.jar')
}
dependencies {
    implementation 'com.android.support:appcompat-v7:+'
}
apply plugin: 'com.google.gms.google-services'

  • OS: Windows 10
  • Android版本: 4.1.2
EN

Stack Overflow用户

发布于 2022-01-29 05:12:09

我得到了AAPT: error: resource :attr/lStar在一个新项目中没有找到,只使用空的活动模板,目标是21的min版本。要解决这个问题,在创建一个新项目的“配置您的项目”步骤中,我必须选中一个复选框,上面写着使用遗留android.support库来运行该项目。显然,这会阻止您使用最新的Play Services和Jetpack库,但这似乎是一个非常次要的问题。

或者,这些都是错误的依赖项,所以在build.gradle (app)中,我可以通过替换

代码语言:javascript
运行
复制
dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 
}

使用

代码语言:javascript
运行
复制
dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
票数 1
EN
查看全部 10 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66413144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档