zl程序教程

您现在的位置是:首页 >  其他

当前栏目

AAPT: error: resource android:attr/lStar not found

2023-04-18 14:27:01 时间

时间:2022年8月9日
新建项目后,layout无法预览,Rebuild报错:Android resource linking failed 
AAPT: error: resource android:attr/lStar not found.

layout界面:

 

 最先查到的方法均无效:

方法1:需要更改编译版本compileSdkVersion升级到31,然后重新编译就能过(Rebuild 不报错,但是layout依然不显示,没有预览信息)

第二:全局搜索项目androidx.core:core-ktx,若没有设置具体版本的修改为具体版本就好(直接pass了【手动狗头】)

第三:若是第三方库使用没有设置具体版本,在app的build.gradle中添加如下,强制项目使用具体的版本
 

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

不报错,但是layout预览依然不显示内容

关于预览不显示问题,尝试以下方法均无效:1、在design界面刷新  2、在design界面更换Theme  3、在res/values/styles.xml文件中style标签parent属性上添加Base. 如小图

 

最后将 androidx.appcompat:appcompat  和

androidx.constraintlayout:constraintlayout 

降级,将创建项目时默认的1.4.2改为1.2.0后,Rebuild正常,layout正常显示,预览正常

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

 修改后: