解决打包APK错误:error: resource android:attr/lStar not found

Flutter在打包APK时,某个插件报错:

build\xxx_flutter\intermediates\merged_res\release\mergeReleaseResources\values\values.xml:94: AAPT: error: resource android:attr/lStar not found.

原因是 flutter 在打包时会检查 compileSdkVersion 和 buildToolsVersion,有些旧的插件没有定义。

解决方法:编辑android/build.gradle文件,在两个subprojects之间插入代码,最终结果如下:

subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

// 插入的解决代码
subprojects {
    afterEvaluate { project ->
        if (project.plugins.hasPlugin("com.android.application") ||
                project.plugins.hasPlugin("com.android.library")) {
            project.android {
                compileSdkVersion 34
                buildToolsVersion "34.0.0"
            }
        }
    }
}

subprojects {
    project.evaluationDependsOn(":app")
}

参考链接:https://stackoverflow.com/questions/69033022/message-error-resource-androidattr-lstar-not-found

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注