安卓项目集成androidx.activity:activity时,报出错误:xxx/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:5395: error: resource android:attr/lStar not found.error: failed linking references.
分析:
1、gradle引入配置:
def activity_version = "1.4.0-alpha02"
// Java language implementation
implementation "androidx.activity:activity:$activity_version"
// Kotlin
implementation "androidx.activity:activity-ktx:$activity_version"
2、项目gradle配置:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
3、项目是全新的项目,还没有引入kotlin,所以不是kotlin版本号的问题。
4、修改compileSdkVersion 和 targetSdkVersion为31后,运行正常了。