Flutter 3.29+使用isar构建失败

执行命令:flutter build apk --release

报错

复制代码
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

FAILURE: Build failed with an exception.                                                                                                                                    

* What went wrong:                                                                                                                                                          
A problem occurred configuring project ':isar_flutter_libs'.                                                                                                                
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.                                                                        
   > Namespace not specified. Specify a namespace in the module's build file: C:\Users\17602\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\isar_flutter_libs-3.1.0+1\android\build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

     If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

* Try:                                                                                                                                                                      
> Run with --stacktrace option to get the stack trace.                                                                                                                      
> Run with --info or --debug option to get more log output.                                                                                                                 
> Run with --scan to get full insights.                                                                                                                                     
> Get more help at https://help.gradle.org.                                                                                                                                 

BUILD FAILED in 1s                                                                                                                                                          
Running Gradle task 'assembleRelease'...                         1,292ms
Gradle task assembleRelease failed with exit code 1
  1. 然后参考:https://github.com/isar/isar/issues/1672

在\android\build.gradle.kts文件中添加以下代码

复制代码
// 添加这部分代码,且当前subprojects 必须是当前文件的第一个subprojects块
subprojects {
    afterEvaluate {
        project.extensions.configure<com.android.build.gradle.BaseExtension> {
            if (namespace == null) namespace = project.group.toString()
        }
    }
}

再次尝试构建,发现会提示另一个错误:

复制代码
FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':isar_flutter_libs:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
Android resource linking failed
ERROR:E:......\build\isar_flutter_libs\intermediates\merged_res\release\values\values.xml:194: AAPT: error: resource android:attr/lStar not found.

Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

Get more help at https://help.gradle.org
  1. 最后再另一个issue里面找到了解决方案:
    https://github.com/isar/isar/issues/1681
    使用以下subprojects 区块代码,替换\android\build.gradle.kts里的所有subprojects 区块
kts 复制代码
subprojects {
    val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
    project.layout.buildDirectory.value(newSubprojectBuildDir)
}

subprojects {
    afterEvaluate {
        if (project.hasProperty("android")) {
            val androidExtension = project.extensions.findByName("android")
            if (androidExtension is com.android.build.gradle.BaseExtension) {
                androidExtension.compileSdkVersion = "android-35"
                androidExtension.buildToolsVersion = "35.0.0"
                androidExtension.ndkVersion = "27.0.12077973"
                if (androidExtension.namespace == null) {
                    androidExtension.namespace = project.group.toString()
                }
            }
        }
    }
}

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

最后再执行构建命令就可以成功构建了

但是后来发现isar在github上已经两年多没更新了,遂切换其他本地数据库

相关推荐
CES_Asia1 小时前
亚洲科技话语权之争:CES Asia 2026核心展区席位进入收官阶段
大数据·人工智能·科技·物联网·机器人
quant_19861 小时前
如何处理大规模行情数据:从源头到终端的实战教程
大数据·开发语言·经验分享·python·金融
房产中介行业研习社1 小时前
市面上比较主流的房产中介管理系统有哪些推荐?
大数据·人工智能·房产直播技巧·房产直播培训
云器科技2 小时前
NinjaVan x 云器Lakehouse: 从传统自建Spark架构升级到新一代湖仓架构
大数据·ai·架构·spark·湖仓平台
泰迪智能科技2 小时前
分享|2025年广东水利电力职业技术学院泰迪数据智能产业学院订单班结业典礼圆满结束
大数据·人工智能
中科天工2 小时前
如何实现工业AI在智能制造中的应用?
大数据·人工智能·智能
Sui_Network3 小时前
Sui 2025→2026 直播回顾中文版
大数据·前端·人工智能·深度学习·区块链
hans汉斯3 小时前
基于数据重构与阈值自适应的信用卡欺诈不平衡分类模型研究
大数据·算法·机器学习·重构·分类·数据挖掘·机器人
l134062082354 小时前
Flutter Geocoding 在鸿蒙上的使用指南
flutter·华为·harmonyos
昌sit!4 小时前
hadoop集群搭建
大数据·hadoop·分布式