即使我的代码没有更改,也会出现“Android 资源链接失败”

Posted

技术标签:

【中文标题】即使我的代码没有更改,也会出现“Android 资源链接失败”【英文标题】:Getting "Android resource linking failed" even though my code has not changed 【发布时间】:2021-12-26 06:39:50 【问题描述】:

最近我在运行我的应用程序时遇到了这个错误:

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\Ved\.gradle\caches\transforms-2\files-2.1\17b6ef056be36c409382a0a8037faedc\core-1.7.0\res\values\values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

还有:

Android resource linking failed
C:\Users\Ved\.gradle\caches\transforms-2\files-2.1\17b6ef056be36c409382a0a8037faedc\core-1.7.0\res\values\values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

当我点击它时,它会将我带到 values.xml 第 150 行:

<declare-styleable name="ColorStateListItem">
        <!-- Base color for this state. -->
        <attr name="android:color"/>
        <!-- Alpha multiplier applied to the base color. -->
        <attr format="float" name="alpha"/>
        <attr name="android:alpha"/>
        <!-- Perceptual luminance applied to the base color. From 0 to 100. -->
        <attr format="float" name="lStar"/>
        <attr name="android:lStar"/>
    </declare-styleable>

我什至没有使用这个样式,但错误仍然存​​在。我已经阅读过有关我的compileSDKandroid-core:core-ktx:+ 的问题的帖子 但是,当我将 SDK 更改为 31 和 android-core:core-ktx:1.7.0 时,它仍然无法正常工作并给我另一个错误。我一直在努力寻找答案,但我没能找到,希望你们中的一个人能找到。 这是我的构建等级:


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android 
    compileSdkVersion 29

    defaultConfig 
        applicationId "com.suad.venttome"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 6
        versionName "1.5"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    

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


dependencies 
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.core:core:1.3.2'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.google.android.material:material:1.3.0-alpha04'
    implementation 'com.jjoe64:graphview:4.2.2'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

    //Passcode view
    implementation 'com.hanks:passcodeview:0.1.2'

    //Material.io implementation
    implementation 'com.google.android.material:material:1.2.0-alpha04'


    //Android Jetpack Navigation
    def nav_version = "2.3.2"
    implementation "androidx.navigation:navigation-fragment:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"
    implementation "androidx.core:core-ktx:+"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

repositories 
    maven  url 'https://dl.bintray.com/kotlin/kotlin-eap' 
    mavenCentral()

与:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript 
    ext.kotlin_version = '1.4.30-M1'
    repositories 
        google()
        jcenter()
        maven  url 'https://dl.bintray.com/kotlin/kotlin-eap' 
    
    dependencies 
        classpath "com.android.tools.build:gradle:4.0.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    


allprojects 
    repositories 
        google()
        jcenter()
        maven  url 'https://jitpack.io' 
    


task clean(type: Delete) 
    delete rootProject.buildDir

如果您有可能的解决方案,我很乐意为她服务。提前致谢!

【问题讨论】:

【参考方案1】:

只是改变

implementation "androidx.core:core-ktx:+"

implementation "androidx.core:core-ktx:1.6.0"

1.7.0 版本对我也不起作用

【讨论】:

不幸的是,这个解决方案也不起作用。相反,我收到此错误Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes artifactType=android-dex, dexing-enable-desugaring=false, dexing-incremental-desugaring-v2=false, dexing-is-debuggable=true, dexing-min-sdk=15. The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle android compileOptions sourceCompatibility 1.8 targetCompatibility 1.8

以上是关于即使我的代码没有更改,也会出现“Android 资源链接失败”的主要内容,如果未能解决你的问题,请参考以下文章

为啥即使没有错误,表单也会出现错误消息?

为啥即使禁用缓存,服务器也会忽略代码文件中的更改?

为啥即使我没有将 vuex 状态绑定到任何 html 输入元素,我的 vuex 状态也会在更改组件级别状态时发生变化?

即使没有分派任何操作,Redux 状态也会在加载时更改

即使哈希没有改变,jQuery地址哈希更改也会触发

即使没有更改,ndk-build也会安装库。这可以改变吗?