11

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Oscar Reyes
  • 4,223
  • 8
  • 41
  • 75
  • Facing this issue, tried to update all my dependencies, gradle wrapper, gradle build and SdkVersion. still not able to fix it, tried with the androidx.core:core-ktx also, no luck .. – Ganesh Sep 02 '21 at 13:35
  • 1
    @Ganesh you can try what was answered below, it's likely that one dependency on your project is building with the latest version, android 12 is starting to show up in the releases which is breaking many stuff on previous versions. i've left an answer as well explaining what was happening how i fixed it – Oscar Reyes Sep 02 '21 at 16:50
  • First I would like to thank you for reply. I am not using androidx.core:core-ktx at all in my project, i agree one of my external libraries will have dependencies, i tried to update and checked each dependencies but none of them look like upgraded to 31, In my case i just updated to 31 and suddenly all things started to mess up.. i degraded all the update version still no help.. no able to build any of it .. – Ganesh Sep 03 '21 at 07:10
  • It is coming in androidx.core:core:1.7.0->values.xml. Log says to increase the minSdkVersion to 24 or above. It went away when changed compileSdkVersion and targetSdkVersion to 31 OS version. – Abhinav Saxena Dec 23 '21 at 12:06

7 Answers7

11

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Oscar Reyes
  • 4,223
  • 8
  • 41
  • 75
  • 1
    Additionally, If you don't have this dependency directly then Under Project Structure in File -> Dependencies Tab, you will be able to find all module dependencies if you search for androidx.core you will get list of external libraries are using this and hence just uninstall and install that dependencies, it will solve the problem .. – Ganesh Sep 03 '21 at 09:09
  • @Ganesh I am facing with same problem but as you said I have no direct dependency to core-ktx but I could not solve the issue – celcin Sep 14 '21 at 10:37
  • @mab, Since you don't have any direct dependencies you need to figure out the library which causing this, go to Project Structure in File -> Dependencies Tab -> Under All Modules -> Under All Dependiencies search/find core-ktx and click then Under Target Modules(right hand side) you able able to get the connected external library – Ganesh Sep 14 '21 at 11:17
  • @Ganesh Do u mean in build.gradle file? btw I am trying to build in docker container – celcin Sep 14 '21 at 11:39
  • 1
    @mab, I am not sure for the docker build generation, but if you able able to write in cmd line, I can help you with this ref, fetch the hierarchy of dependencies and find core-ktx and try installing and uninstalling technique, hope its solve your problem.. https://stackoverflow.com/questions/21645071/using-gradle-to-find-dependency-tree – Ganesh Sep 14 '21 at 11:58
  • @Ganesh Thanks for the answers, I solved them by investing in subprojects and adding a force core strategy. In root level somehow doesn't work – celcin Sep 14 '21 at 12:08
  • 1
    It is coming in androidx.core:core:1.7.0->values.xml. Log says to increase the minSdkVersion to 24 or above. It went away when changed compileSdkVersion and targetSdkVersion to 31 OS version. – Abhinav Saxena Dec 23 '21 at 12:07
  • @AbhinavSaxena and Ganesh's Answer worked for me. Thanks – Kenny Dabiri Aug 01 '22 at 17:52
3

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Airton
  • 31
  • 4
2

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kaiattrib
  • 101
  • 6
0

Are you using the netinfo library? You need to refresh this library if you are using it.

After updating or uninstalling and reinstalling the netinfo library it will work.

  • 1
    The issue was just about a dependency not being locked to a version, the build was starting to fail because the dependency was using the latest version which is for android 12 since beta started rolling out. – Oscar Reyes Sep 02 '21 at 19:25
  • Please add further details to expand on your answer, such as working code or documentation citations. – Community Sep 03 '21 at 00:14
0

I had used this and it works for me.

  android {  
    configurations.all {
        resolutionStrategy {
            force 'androidx.core:core-ktx:1.6.0'
        }
     }
}
hassan mirza
  • 139
  • 2
  • 8
0

check you added the correct version of

implementation 'com.google.android.material:material:1.3.0'

in dependencies

soma
  • 61
  • 1
  • 10
0

I used appcompat lib as:

implementation("androidx.appcompat:appcompat:1.3.1")
implementation("androidx.appcompat:appcompat-resources:1.3.1")

Kotlin version as 1.6.0

And it works for me

Quốc Hùng
  • 106
  • 1
  • 7