首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android资源链接失败错误

Android资源链接失败错误
EN

Stack Overflow用户
提问于 2021-03-18 03:21:30
回答 2查看 177关注 0票数 0

尝试运行一个以前工作正常的项目。我已经几周没有对这个项目做任何改变了。突然,当我尝试运行它时,我得到了一堆错误。我清理了项目,使缓存失效,重新安装了Android studio,似乎没有什么能纠正它。

我能够通过在不同的位置重新安装sdk来完成gradle同步,但资源链接问题仍然存在。

代码语言:javascript
运行
复制
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\Desktop\\RESTORED-BOMI_ACRM\\app\\src\\main\\res\\values-v21\\styles.xml","position":{"startLine":2,"startColumn":4,"startOffset":20,"endLine":6,"endColumn":12,"endOffset":242}}],"original":"C:\\Users\\myusername\\Desktop\\RESTORED-BOMI_ACRM\\app\\src\\main\\res\\values-v21\\styles.xml:3:5-7:13: AAPT: error: style attribute 'android:attr/windowDrawsSystemBarBackgrounds' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml","position":{"startLine":1500,"startColumn":4,"startOffset":84224,"endLine":1504,"endColumn":12,"endOffset":84495}}],"original":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml:1501:5-1505:13: AAPT: error: style attribute 'android:attr/textAllCaps' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml","position":{"startLine":1529,"startColumn":4,"startOffset":85874,"endLine":1534,"endColumn":12,"endOffset":86288}}],"original":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml:1530:5-1535:13: AAPT: error: resource android:attr/textColorHighlightInverse not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml","position":{"startLine":1529,"startColumn":4,"startOffset":85874,"endLine":1534,"endColumn":12,"endOffset":86288}}],"original":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml:1530:5-1535:13: AAPT: error: resource android:attr/textColorLinkInverse not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml","position":{"startLine":1539,"startColumn":4,"startOffset":86519,"endLine":1544,"endColumn":12,"endOffset":86939}}],"original":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml:1540:5-1545:13: AAPT: error: resource android:attr/textColorHighlightInverse not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml","position":{"startLine":1539,"startColumn":4,"startOffset":86519,"endLine":1544,"endColumn":12,"endOffset":86939}}],"original":"C:\\Users\\myusername\\.gradle\\caches\\transforms-2\\files-2.1\\65bf90c48b89b41813cde0a04f1b73cc\\appcompat-v7-28.0.0\\res\\values\\values.xml:1540:5-1545:13: AAPT: error: resource android:attr/textColorLinkInverse not found.\n    ","tool":"AAPT"}

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\myusername\Desktop\RESTORED-BOMI_ACRM\app\src\main\res\values-v21\styles.xml:3:5-7:13: AAPT: error: style attribute 'android:attr/windowDrawsSystemBarBackgrounds' not found.
         
     C:\Users\myusername\.gradle\caches\transforms-2\files-2.1\65bf90c48b89b41813cde0a04f1b73cc\appcompat-v7-28.0.0\res\values\values.xml:1501:5-1505:13: AAPT: error: style attribute 'android:attr/textAllCaps' not found.
         
     C:\Users\myusername\.gradle\caches\transforms-2\files-2.1\65bf90c48b89b41813cde0a04f1b73cc\appcompat-v7-28.0.0\res\values\values.xml:1530:5-1535:13: AAPT: error: resource android:attr/textColorHighlightInverse not found.
         
     C:\Users\myusername\.gradle\caches\transforms-2\files-2.1\65bf90c48b89b41813cde0a04f1b73cc\appcompat-v7-28.0.0\res\values\values.xml:1530:5-1535:13: AAPT: error: resource android:attr/textColorLinkInverse not found.
         
     C:\Users\myusername\.gradle\caches\transforms-2\files-2.1\65bf90c48b89b41813cde0a04f1b73cc\appcompat-v7-28.0.0\res\values\values.xml:1540:5-1545:13: AAPT: error: resource android:attr/textColorHighlightInverse not found.
         
     C:\Users\myusername\.gradle\caches\transforms-2\files-2.1\65bf90c48b89b41813cde0a04f1b73cc\appcompat-v7-28.0.0\res\values\values.xml:1540:5-1545:13: AAPT: error: resource android:attr/textColorLinkInverse not found.
         

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
55 actionable tasks: 4 executed, 51 up-to-date

这是我的build.Gradle

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

android {
    compileSdkVersion 26
    buildToolsVersion '29.0.2'
    defaultConfig {
        applicationId "com.myappname"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 2
        versionName '2.0.1'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    useLibrary 'org.apache.http.legacy'
    productFlavors {
    }
}
repositories {
    flatDir {
        dirs 'libs' }
    maven { url 'https://maven.google.com' }
    maven { url 'https://jitpack.io' }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    api fileTree(include: ['*.jar'], dir: 'libs')
    api('com.mikepenz:materialdrawer:5.1.6@aar') {
        transitive = true
    }
    api('com.mikepenz:crossfadedrawerlayout:0.3.3@aar') {
        transitive = true
    }
    // https://mvnrepository.com/artifact/com.android.volley/volley
    api 'com.android.volley:volley:1.2.0'
    api fileTree(include: ['*.jar'], dir: 'libs')
    api 'com.android.support.constraint:constraint-layout:2.0.4'
    //noinspection GradleCompatible
    api 'com.android.support:preference-v7:26.1.0'
    api files('libs/gson-2.7.jar')
    api project(':aFileDialog')
    api 'com.android.support:appcompat-v7:26.1.0'
    api 'com.android.support:design:26.1.0'
    api 'com.google.android.gms:play-services-appindexing:9.8.0'
    api 'com.android.support:support-v4:26.1.0'
    api 'com.android.support:recyclerview-v7:26.1.0'
    api 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
    implementation 'com.github.pratikbutani:MultiSelectSpinner:08d324c987'
    implementation 'com.github.chrisbanes:PhotoView:2.0.0'

再说一次,这在以前运行得很好。几周来我什么都没改。我甚至尝试过迁移到AndroidX,但仍然会抛出相同的gradle错误。

EN

回答 2

Stack Overflow用户

发布于 2021-03-18 20:51:02

检查是否在您的任何布局中放置了

代码语言:javascript
运行
复制
android:attr/textAllCaps

代替

代码语言:javascript
运行
复制
android:?attr/textAllCaps
票数 0
EN

Stack Overflow用户

发布于 2021-03-19 21:57:06

我必须将以下内容添加到我的项目build.gradle中

代码语言:javascript
运行
复制
   subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion = 26
                        buildToolsVersion = '29.0.2'
                    }
                }
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66679865

复制
相关文章

相似问题

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