79641716

Date: 2025-05-28 07:38:50
Score: 1.5
Natty:
Report link

In my case, i facing this:

Gradle build failed to produce an .aab file. It's likely that this file was generated under app_name/build, but the tool couldn't find it.

but the BUILD SUCCESSFUL in 1m 50s, and i can find the .aab file in

app_name/build/app/outputs/bundle/release/appName-2.0.0-v2-release.aab

What's really happens:

This is happens because Flutter expects a default output filename, but you have customized the AAB file name. I customize archieveBaseName in android/app/build.gradle become like this:

android {
    ....

    defaultConfig {
        archivesBaseName = "${appName}-${flutterVersionName}-v${flutterVersionCode}"
    }
}

Whereas Flutter looks for the default file at:

build/app/outputs/bundle/release/app-release.aab

So even though the build succeeded and the file was generated, Flutter reports:

Gradle build failed to produce an .aab file.

because it can’t find app-release.aab where it expects it.

How i fix it?

I only customize the output name for .apk file. Here is how i customize it in android/app/build.gradle:

android {
    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                def newName = "${appName}-${flutterVersionName}-v${flutterVersionCode}-${variant.name}.apk"
                output.outputFileName = newName
            }
        }
    }
    
    ...
}

and remove the customization for archieveBaseName in build.gradle .

Reasons:
  • RegEx Blacklisted phrase (1.5): fix it?
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Daud Dhiya'