Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Resource linking fails on test execution even when nothing has been changed

Tags:

android

I'm starting to get errors when I am executing a test for a release variant which was always working fine. The code has always been executed in a Docker container so we can ensure that the build will always be clean.

Today for some reason with no changes at all to the code, I am starting to see errors on the test run:

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.

I've made some research about the error, but I only find errors related to another resource, but nothing about lStar. So far about, I have found that lStar is code added to Android 31 (Android 12) in particular, which makes no sense to me why it should start working on Android 12 if my compileSdkVersion value is 28.

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

What could be the cause of this error even though nothing has been changed?

like image 608
Oscar Reyes Avatar asked Sep 01 '21 19:09

Oscar Reyes


People also ask

What is Android resource linking failed?

The following error typically occurs in Unity 2019 and indicates that your Gradle version does not support AndroidX: /Temp/gradleOut/launcher/build/intermediates/merged_manifests/release/AndroidManifest.

Why does resource linking fail on test execution?

According to Android: Resource linking fails on test execution even when nothing has been changed, this happened because some library got upgraded. lStar needs compileSdkVersion 31 and my project used compileSdkVersion 28. How can I track which libraries got updated recently, or which library is causing this?

What to do when resource linking fails on Android?

Warning: Android resource linking failed,error: failed linking references。 In the above figure, you will find that the compile sdk version and the build tools version are not the same, so change the build tools version to 26. Run again successfully.

Why did my test run fail?

Tests on test (AVD) - 11 failed: Instrumentation run failed due to 'Process crashed.' No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations). Sorry, something went wrong. Sorry, something went wrong.

How to fix resource Android ATTR/LStar not found issue?

No more error: resource android attr/lStar not found issue ! To sum-up : check your plugins dependencies and if possible, set static versions instead of "latest". In that way, you can (in most cases) avoid using alpha/beta releases, which could be instable or not supporting your current environment. Show activity on this post.


Video Answer


3 Answers

I've found the issue and I was able to fix it.

The issue was that one of the external libraries the app depends on has a dependency on androidx.core:core-ktx:+ which meant that was always compiling with the latest version. My app is still working on SDK 28, but the latest version of androidx.core:core-ktx has the minimal SDK of 31, which resulted in this conflict.

like image 149
Oscar Reyes Avatar answered Oct 27 '22 06:10

Oscar Reyes


I changed the line androidx.core:core-ktx:+ to androidx.core:core-ktx:1.6.0 in the build.gradle, and it worked for me.

like image 29
Airton Avatar answered Oct 27 '22 07:10

Airton


What could be the cause of this error even though nothing has been changed?

As we can see in https://developer.android.com/jetpack/androidx/releases/core#1.7.0-alpha02, Core and Core-ktx Version 1.7.0-alpha02 was released on September 1, 2021.

If you used like androidx.core:core-ktx:+, it would find the last version.

So, on the September 1, 2021, it may be 1.7.0-alpha01 that was not adding the attribute "android:lStar" which need the Android 31 compile SDK. It's a bug.


How can we fix it?

  • use a specific version, use androidx.core:core-ktx:${version} instead of androidx.core:core-ktx:+
  • upgrade the compile SDK to Android 31
like image 22
kaiattrib Avatar answered Oct 27 '22 07:10

kaiattrib