flutterbuild.gradle

Flutter Build failed with an exception after update


Can you please help me what to do: my app built great, until I updated flutter. Now I've got this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_mailer:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:C:\Users\zinch\.gradle\caches\transforms-3\008d07c96b1472e89d5ddc7f299cab36\transformed\core-1.13.1\res\values\values.xml:113:5-122:25: AAPT: error: resource android:attr/lStar not found.

I don't use flutter_mailer in my project.

Flutter clean and invalidate cache didn't help.

Output of flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.0, on Microsoft Windows [Version 10.0.19045.4780], locale ru-RU)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.1)
[√] Android Studio (version 2023.2)
[√] Android Studio (version 2024.1)
[√] Connected device (4 available)
[√] Network resources

Solution

  • As Edmund Tam wrote in comment, the solution is written here https://github.com/flutter/flutter/issues/153281#issuecomment-2292201697.

    replacing your subprojects block in your <project_root>/android/build.gradle with something along the lines of:

    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
                    }
                }
            }
        }
        
    }
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
        project.evaluationDependsOn(":app")
    }
    

    Second subprojects block is required, or you've got an error while building.