Skip to content

flutter build doesn't work for appbundle with few flavor dimensions #92316

@Albert221

Description

@Albert221

Given two flavor dimensions: app and type

  • example being in the app dimension
  • prod being in the type dimension

and Flutter build command: flutter build appbundle --release --flavor exampleProd --verbose flutter_tools is looking for the AAB file in:

  • build/app/outputs/bundle/release/app.aab
  • build/app/outputs/bundle/release/app-release.aab
  • build/app/outputs/bundle/exampleprodRelease/app.aab
  • build/app/outputs/bundle/exampleprodRelease/app-exampleprod-release.aab

And it's actually located inbuild/app/outputs/bundle/exampleProdRelease/app-example-prod-release.aab therefore the command fails to complete sucessfully.

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

Related flutter_tools source code:

@visibleForTesting
File findBundleFile(FlutterProject project, BuildInfo buildInfo, Logger logger, Usage usage) {
final List<File> fileCandidates = <File>[
getBundleDirectory(project)
.childDirectory(camelCase(buildInfo.modeName))
.childFile('app.aab'),
getBundleDirectory(project)
.childDirectory(camelCase(buildInfo.modeName))
.childFile('app-${buildInfo.modeName}.aab'),
];
if (buildInfo.flavor != null) {
// The Android Gradle plugin 3.0.0 adds the flavor name to the path.
// For example: In release mode, if the flavor name is `foo_bar`, then
// the directory name is `foo_barRelease`.
fileCandidates.add(
getBundleDirectory(project)
.childDirectory('${buildInfo.lowerCasedFlavor}${camelCase('_${buildInfo.modeName}')}')
.childFile('app.aab'));
// The Android Gradle plugin 3.5.0 adds the flavor name to file name.
// For example: In release mode, if the flavor name is `foo_bar`, then
// the file name name is `app-foo_bar-release.aab`.
fileCandidates.add(
getBundleDirectory(project)
.childDirectory('${buildInfo.lowerCasedFlavor}${camelCase('_${buildInfo.modeName}')}')
.childFile('app-${buildInfo.lowerCasedFlavor}-${buildInfo.modeName}.aab'));
}
for (final File bundleFile in fileCandidates) {
if (bundleFile.existsSync()) {
return bundleFile;
}
}
_exitWithExpectedFileNotFound(
project: project,
fileExtension: '.aab',
logger: logger,
usage: usage,
);
}

Flutter 2.5.1 • channel unknown • unknown source
Framework • revision ffb2ecea52 (5 weeks ago) • 2021-09-17 15:26:33 -0400
Engine • revision b3af521a05
Tools • Dart 2.14.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toolfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions