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
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.
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
.