error: resource android:attr/lStar not found [Pefect Solution]

Today, the following errors suddenly appear in the project, and the compilation will report an error

D:\AndroidProjects\XXXXX\app\build\intermediates\incremental\mergeDebugResources\
merged.dir\values\values.xml:10858: AAPT: error: resource android:attr/lStar not found.

No one submitted the code. I could still run yesterday, but I suddenly couldn’t do it today. Then there were all kinds of tosses. I tried the common methods for difficult and miscellaneous problems in the development process. Clean project, clear the studio cache and restart, restart the computer, etc. the problems still exist. I searched for a circle and didn’t find the corresponding solutions.

Problem:

The project or third-party library relies on androidx.core: core KTX: + , and there is no limited version. Therefore, the latest core KTX version 1.7.0 is used, and the above compilation error is reported, and it is still sudden.

 

Solution:

The specific version number depends on the project, not necessarily 1.3.2. I understand that it can be lower than 1.7.0

Method 1: project reference and directly set the specific version number. For example, my project:
implementation "Android. Core: core KTX: 1.3.2"
method 2: the version number is not set in the third-party dependency library. You can add the following code in build.gradle of APP module:
at the same level as Android {}

configurations.all {
    resolutionStrategy {
        force 'androidx.core:core-ktx:1.3.2'
    }
}

Note: the specific version number of remote dependency must be set. Never use the + end. This compilation will pull the corresponding latest remote dependency. Maybe there will be an inexplicable problem that day.

Read More: