From 78b42a9d068c0165d2d58adc591ef3888a76f502 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 18 Aug 2024 03:18:19 +0800 Subject: [PATCH] android: Increase compileSdkVersion to 31 for all plugins This commit updates the `compileSdkVersion` for all plugins to resolve the `android:attr/lStar not found` error encountered during build. It adjusts the compile SDK version to 31 to align with AndroidX dependencies and newer Android SDK requirements. This change is made in the `subprojects` section of the `android/build.gradle` file to ensure all plugins adhere to this version without manual updates. https://github.com/flutter/flutter/issues/153281#issuecomment-2292201697 --- src/ui/flutter_app/android/build.gradle | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ui/flutter_app/android/build.gradle b/src/ui/flutter_app/android/build.gradle index 18437ee736..a63a8001fd 100644 --- a/src/ui/flutter_app/android/build.gradle +++ b/src/ui/flutter_app/android/build.gradle @@ -7,8 +7,29 @@ allprojects { rootProject.buildDir = '../build' subprojects { + afterEvaluate { project -> + if (project.extensions.findByName("android") != null) { + Integer pluginCompileSdk = project.android.compileSdk + if (pluginCompileSdk != null && pluginCompileSdk < 31) { + project.logger.error( + "Warning: Overriding compileSdk version in Flutter plugin: " + + project.name + + " from " + + pluginCompileSdk + + " to 31 (to work around https://issuetracker.google.com/issues/199180389)." + + "\nIf there is not a new version of " + project.name + ", consider filing an issue against " + + project.name + + " to increase their compileSdk to the latest (otherwise try updating to the latest version)." + ) + project.android { + compileSdk 31 + } + } + } + } + project.buildDir = "${rootProject.buildDir}/${project.name}" - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) {