allprojects { repositories { google() mavenCentral() } } def newBuildDir = rootProject.layout.buildDirectory.dir("../../build").get() rootProject.layout.buildDirectory.set(newBuildDir) subprojects { def newSubprojectBuildDir = newBuildDir.dir(project.name) project.layout.buildDirectory.set(newSubprojectBuildDir) } subprojects { project.evaluationDependsOn(":app") plugins.whenPluginAdded { plugin -> // 修复点1:增加空安全判断 + 仅针对Android/Java插件(排除系统插件) def pluginName = plugin.getClass().simpleName if (pluginName in ['AndroidPlugin', 'JavaPlugin', 'JavaLibraryPlugin']) { // 修复点2:仅在任务创建时拦截目标项目的UnitTest任务 tasks.whenTaskAdded { task -> // 仅处理flutter_plugin_android_lifecycle项目,忽略其他插件(如audioplayers_android) if (project.path == ':flutter_plugin_android_lifecycle') { // 精准禁用报错任务,避免波及其他插件 def targetTasks = [ 'compileDebugUnitTestSources', 'testDebugUnitTest', 'compileReleaseUnitTestSources', 'testReleaseUnitTest' ] if (targetTasks.contains(task.name)) { task.enabled = false println("Disabled task: ${task.name} for flutter_plugin_android_lifecycle (resolve path error)") } } } } } } tasks.register("clean", Delete) { delete rootProject.layout.buildDirectory delete project(":app").layout.buildDirectory }