首页 > 解决方案 > Android:即使没有任何更改,资源链接在测试执行时也会失败

问题描述

当我对始终运行良好的发布变体执行测试时,我开始出现错误。代码始终在 Docker 容器中执行,因此我们可以确保构建始终是干净的。

今天由于某种原因,代码完全没有变化,我开始在测试运行中看到错误:

Execution failed for task:
am:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /.gradle/caches/transforms-2/files-2.1/ff28653768e2ccb1135467db3600af3a/core-1.7.0-alpha02/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

我对该错误进行了一些研究,但我只发现与另一个资源相关的错误,但没有发现关于 lStar 的错误。到目前为止,我发现 lStar 特别是添加到 Android 31(Android 12)的代码,这对我来说没有意义,如果我的 compileSdkVersion 值为 28,它为什么应该开始在 Android 12 上工作。

<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>

即使没有任何更改,此错误的原因可能是什么?

标签: android

解决方案


我发现了问题,并且能够解决它。

问题是应用程序所依赖的外部库之一具有依赖关系,androidx.core:core-ktx:+这意味着它始终使用最新版本进行编译。我的应用程序仍在使用 SDK 28,但最新版本androidx.core:core-ktx的最小 SDK 为 31,这导致了此冲突。


推荐阅读