You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter构建报错::printing:verifyReleaseResources任务执行失败,找不到android:attr/lStar

Android构建错误:找不到资源android:attr/lStar的解决方法

问题描述

构建过程中出现异常,任务:printing:verifyReleaseResources执行失败,触发Android资源链接错误,具体提示:/Users/mac/Documents/FlutterDev/flutter_projects/ledgerBook/build/printing/intermediates/merged_res/release/values/values.xml:194: AAPT: 错误:找不到资源 android:attr/lStar。

解决步骤

  • 检查并提升编译SDK版本
    android:attr/lStar是Android 12(API级别31)新增的属性,需确保项目build.gradle(app模块或项目级)中compileSdkVersion设置为31或更高:

    android {
        compileSdkVersion 31 // 可设置为更高的稳定版本
        // 其他配置项
    }
    
  • 统一模块的编译版本(Flutter项目适用)
    若依赖的printing插件使用了更高的编译SDK版本,可能引发资源冲突。在项目根目录的android/build.gradle中添加全局配置,强制所有模块使用统一版本:

    subprojects {
        afterEvaluate {
            if (it.hasProperty('android')) {
                android {
                    compileSdkVersion 31
                    targetSdkVersion 31
                }
            }
        }
    }
    
  • 更新AndroidX核心依赖
    确保androidx.core相关依赖版本适配API31,在app/build.gradle中更新:

    dependencies {
        implementation 'androidx.core:core-ktx:1.7.0'
        // 其他依赖
    }
    
  • 清理构建缓存后重新构建
    执行以下命令清理缓存并重新打包:

    flutter clean
    flutter pub get
    cd android && ./gradlew clean
    cd .. && flutter build apk --release
    

内容的提问来源于stack exchange,提问作者Sahil Viradiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 19:39:58