Can't build an .aab in Flutter

Viewed 842

When i'm running

flutter build appbundle

I'm getting the next error:

Gradle build failed to produce an .aab file. Its likely that this file was generated under /path_to_project/build, but the tool couldnt find it.

But i still can create an apk. And i can create an appbundle of a new-created projected.

So, what should i fix to get an opportunity to build .aab? I can't just build a new project and switch code, because this is a 2-years project with some special lines in native code and idk where, because the previous developer added them, not me and i don't have an any connections with him :c

2 Answers

Previously, I was releasing APKs and I switched the project to AAB. The issue was that I was setting my archivesBaseName in my build.gradle to contain more useful information:

defaultConfig {
    (..)
    setProperty("archivesBaseName", applicationId + "." + flutterVersionName + "." + flutterVersionCode)
}

This was really a bad idea when switching to AAB, because Gradle would search for a app-release.aab, thus I would end up with this error message.

The obvious solution is to remove that line, so the output filename is correct.

Okay, i had kinda outadated gradle version. So i've changed it in

  • myproject/android/gradle/wrapper/gradle-wrapper.properties
  • myproject/android/build.gradle

And thats all! Latest version i got from another flutter proj (i just ran flutter create and looked into files of the new project).

Related