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?
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.
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?
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.
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.
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.
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.
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.
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?
androidx.core:core-ktx:${version}
instead of androidx.core:core-ktx:+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With