allprojects { repositories { google() mavenCentral() } } val newBuildDir: Directory = rootProject.layout.buildDirectory .dir("../../build") .get() rootProject.layout.buildDirectory.value(newBuildDir) subprojects { val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) project.layout.buildDirectory.value(newSubprojectBuildDir) } // flutter_secure_storage 11 requests compileSdk 37; some SDKs install that // platform as android-37.0, which AGP cannot resolve. Cap plugins at 36. subprojects { afterEvaluate { val android = project.extensions.findByName("android") ?: return@afterEvaluate try { val method = android.javaClass.methods.firstOrNull { it.name == "setCompileSdkVersion" || it.name == "setCompileSdk" } // Prefer the Int setter used by AGP 8+ val setCompileSdk = android.javaClass.methods.firstOrNull { m -> m.name == "setCompileSdk" && m.parameterTypes.size == 1 } if (setCompileSdk != null) { val current = android.javaClass.methods .firstOrNull { it.name == "getCompileSdk" && it.parameterCount == 0 } ?.invoke(android) val api = when (current) { is Int -> current is String -> current.toIntOrNull() ?: 0 else -> 0 } if (api > 36) { setCompileSdk.invoke(android, 36) } } else if (method != null) { method.invoke(android, 36) } } catch (_: Exception) { // Non-Android subprojects — ignore. } } } subprojects { project.evaluationDependsOn(":app") } tasks.register("clean") { delete(rootProject.layout.buildDirectory) }