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上已经两年多没更新了,遂切换其他本地数据库

相关推荐
百胜软件@百胜软件8 小时前
新零售模式下仓储变化与发展趋势
大数据·零售
lisw058 小时前
编程语言top5对比分析!
大数据·人工智能·程序人生·机器学习·软件工程
打码人的日常分享8 小时前
信息化系统安全建设方案
大数据·数据库·人工智能·安全·系统安全
幂简集成8 小时前
需求从0到1:AI提示词助力客户画像→功能脑暴→PRD→价值主张
大数据·人工智能
lifallen9 小时前
Flink TCP Channel复用:NettyServer、NettyProtocol详解
大数据·flink·nio
Hello.Reader9 小时前
用 Flink 打造事件驱动流式应用从 DataStream 到 ProcessFunction
大数据·flink
jqy202510 小时前
什么是合同管理系统?6个核心功能介绍
大数据·合同 管理系统·电子合同管理
韩立学长10 小时前
【开题答辩实录分享】以《基于大数据的私人牙科诊所病例管理系统》为例进行答辩实录分享
大数据·管理系统
计算机编程小央姐10 小时前
大数据毕业设计选题推荐:基于Hadoop+Spark的全球能源消耗数据分析与可视化系统
大数据·hadoop·数据分析·spark·课程设计·毕设
计算机编程小央姐10 小时前
企业级大数据技术栈:基于Hadoop+Spark的全球经济指标分析与可视化系统实践
大数据·hadoop·hdfs·spark·echarts·numpy·课程设计