Skip to content

when building app bundle with multiple flavorDimension, tool cannot locate .aab file  #65264

Description

@brightknight08

I was having trouble building a flutter app with 2 flavor dimensions and 2 flavors for each dimension (total of 4 variants,
excluding the debug and release modes).

here's a minimal flutter app repo: https://github.com/brightknight08/flutter_build_appbundle_error to reproduce

when I do flutter build appbundle --release --flavor signedprod, it would display

Gradle build failed to produce an .aab file. It's likely that this file was generated under
E:\lab\flutter_build_appbundle_error\build, but the tool couldn't find it.

flutter doctor -v

PS E:\lab\flutter_build_appbundle_error> flutter doctor -v
[✓] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.19041.450], locale en-US)
    • Flutter version 1.20.2 at C:\flutter
    • Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at E:\asdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = E:\asdk
    • Java binary at: E:\as\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 4.0)
    • Android Studio at E:\as
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] VS Code (version 1.48.2)
    • VS Code at C:\Users\tim_m\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.14.0

[✓] Connected device (1 available)
    • P[redacted]...droid-arm64 • Android 10 (API 29)

• No issues found!
PS E:\lab\flutter_build_appbundle_error>

Activity

  1. TahaTesser commented on Sep 7, 2020

    @TahaTesser
    Contributor

    Hi @brightknight08
    Can you please try this solution
    Thank you

  2. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 7, 2020
  3. brightknight08 commented on Sep 9, 2020

    @brightknight08
    Author

    thank you for pointing me in that direction @TahaTesser . is this the supposed "fix"?

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 9, 2020
  5. TahaTesser commented on Sep 9, 2020

    @TahaTesser
    Contributor

    Hi @brightknight08
    Wanted to make sure if it the same issue or not, if the workaround is working or not, it's for APK but after more testing, APK builds without using that workaround. The issue is only app bundle only..aab file is generated if you go build but the tool can't locate

    Screenshot 2020-09-09 at 2 08 17 PM

    flutter build apk --release --flavor signedprod
    Interestingly, it works with APK

    You are building a fat APK that includes binaries for android-arm,
    android-arm64, android-x64.
    If you are deploying the app to the Play Store, it's recommended to use app
    bundles or split the APK to reduce the APK size.
        To generate an app bundle, run:
            flutter build appbundle --target-platform
            android-arm,android-arm64,android-x64
            Learn more on: https://developer.android.com/guide/app-bundle
        To split the APKs per ABI, run:
            flutter build apk --target-platform
            android-arm,android-arm64,android-x64 --split-per-abi
            Learn more on:
            https://developer.android.com/studio/build/configure-apk-splits#configur
            e-abi-split
    Removed unused resources: Binary resource data reduced from 46KB to 37KB: Removed 20%
    Running Gradle task 'assembleSignedprodRelease'...                      
    Running Gradle task 'assembleSignedprodRelease'... Done            15.3s
    ✓ Built build/app/outputs/flutter-apk/app-signedprod-release.apk (15.3MB)

    flutter build appbundle --release --flavor signedprod
    appbundle_logs.txt

    flutter doctor -v
    [✓] Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.6 19G2021, locale en-GB)
        • Flutter version 1.20.3 at /Users/tahatesser/Code/flutter_stable
        • Framework revision 216dee60c0 (8 days ago), 2020-09-01 12:24:47 -0700
        • Engine revision d1bc06f032
        • Dart version 2.9.2
    
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/tahatesser/Code/sdk
        • Platform android-30, build-tools 30.0.2
        • ANDROID_HOME = /Users/tahatesser/Code/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.7)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.7, Build version 11E801a
        • CocoaPods version 1.9.3
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 49.0.2
        • Dart plugin version 193.7547
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [✓] VS Code (version 1.48.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.14.1
    
    [!] Connected device
        ! No devices available
    
    ! Doctor found issues in 1 category.
    
    flutter doctor -v
    [✓] Flutter (Channel master, 1.22.0-10.0.pre.107, on Mac OS X 10.15.6 19G2021, locale en-GB)
        • Flutter version 1.22.0-10.0.pre.107 at /Users/tahatesser/Code/flutter_master
        • Framework revision 54ade88365 (4 hours ago), 2020-09-08 22:08:57 -0700
        • Engine revision d1d848e842
        • Dart version 2.10.0 (build 2.10.0-98.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/tahatesser/Code/sdk
        • Platform android-30, build-tools 30.0.2
        • ANDROID_HOME = /Users/tahatesser/Code/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.7)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.7, Build version 11E801a
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 49.0.2
        • Dart plugin version 193.7547
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    
    [✓] VS Code (version 1.48.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.14.1
    
     
    [✓] Connected device (3 available)            
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64  • Android 10 (API 29)
        • Web Server (web) • web-server       • web-javascript • Flutter Tools
        • Chrome (web)     • chrome           • web-javascript • Google Chrome 85.0.4183.83
    
    • No issues found!
    
    
  6. added
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-androidAndroid applications specifically
    t: gradle"flutter build" and "flutter run" on Android
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Sep 9, 2020
  7. 17 remaining items

  8. adgeg commented on Apr 13, 2023

    @adgeg

    Leaving another note here, cause I've been struggled for many hours 💩. @PiotrWpl solution was working perfectly fine on my laptop, but not on my project's CI/CD (Github Actions), with a strange log "Skipping task copyAndRenameAab[...] as it has no source files and no previous output files".

    @PiotrWpl solution works perfectly on Mac OS and Windows, but not on Ubuntu, as it is a case sensitive OS. So for people having the same issue, you need to add something additional to make it works on all OS. In @PiotrWpl solution,originalDirPath is always in lower case, you need this to make it with proper case (only changes are productFlavorsCapitalized and new value of originalDirPath):

        applicationVariants.all { variant ->
            variant.outputs.all {
                def taskSuffix = variant.name.capitalize()
                def bundleTaskName = "bundle${taskSuffix}"
                if (tasks.findByName(bundleTaskName)) {
                    def copyAABTask = tasks.create(name: "copyAndRenameAab${taskSuffix}", type: Copy) {
                        def bundleBuildDir = "${buildDir}/outputs/bundle"
                        def flavorsCapitalized = variant.productFlavors.name.withIndex().collect { flavor, index -> index == 0 ? flavor : flavor.capitalize() }
                        def originalDirPath = "${flavorsCapitalized.join()}${variant.buildType.name.capitalize()}"
                        def originalFileName = "${project.archivesBaseName}-${variant.productFlavors.name.join('-')}-${variant.buildType.name}.aab"
                        from "${bundleBuildDir}/${originalDirPath}/${originalFileName}"
                        into "${bundleBuildDir}/${variant.buildType.name}/"
                        rename("${originalFileName}", "app.aab")
                    }
                    tasks[bundleTaskName].finalizedBy = [copyAABTask]
                }
            }
        }

    Hope this may help.

    Edit : I should have looked more carefully @btrautmann comment…

  9. exaby73 commented on Apr 18, 2023

    @exaby73
    Member

    I can still reproduce this issue with Master (3.10.0-7.0.pre.17).

    Logs
    # Building appbundle fails
    issue_65264 ❯ fl build appbundle --flavor signedprod
    
    Upgrading build.gradle
    Running Gradle task 'bundleSignedprodRelease'...
    Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1336 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Running Gradle task 'bundleSignedprodRelease'...                   34.0s
    Gradle build failed to produce an .aab file. It's likely that this file was generated under /Users/nabeelparkar/dev/nevercode/issue_65264/build, but the tool couldn't find it.
    
    # Building APK works fine
    issue_65264 ❯ fl build apk --flavor signedprod
    
    Running Gradle task 'assembleSignedprodRelease'...                  5.4s
    ✓  Built build/app/outputs/flutter-apk/app-signedprod-release.apk (17.0MB).
    flutter doctor -v (Master)
    [!] Flutter (Channel master, 3.10.0-7.0.pre.17, on macOS 13.3.1 22E261 darwin-arm64, locale en-US)
        • Flutter version 3.10.0-7.0.pre.17 on channel master at /Users/nabeelparkar/fvm/versions/master
        ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nabeelparkar/fvm/versions/master. Consider adding /Users/nabeelparkar/fvm/versions/master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 3ba249a6b3 (77 minutes ago), 2023-04-18 10:46:33 +0530
        • Engine revision c4396f9f60
        • Dart version 3.1.0 (build 3.1.0-12.0.dev)
        • DevTools version 2.23.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
        • Android SDK at /Users/nabeelparkar/Library/Android/sdk/
        • Platform android-33, build-tools 33.0.2
        • ANDROID_SDK_ROOT = /Users/nabeelparkar/Library/Android/sdk/
        • Java binary at: /Users/nabeelparkar/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.0
    
    [✓] Chrome - develop for the web
        • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
    
    [✓] Android Studio (version 2022.1)
        • Android Studio at /Users/nabeelparkar/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nabeelparkar/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.77.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.62.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 13.3.1 22E261 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Brave Browser 112.1.50.119
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  10. gnprice commented on May 5, 2023

    @gnprice
    Member

    There's some experimentation and discussion on #124797 (thanks @pepompeu!) which I think will be helpful for resolving this issue.

    See in particular @andrewkolos's repro recipe at #124797 (comment), and my suggestion at #124797 (comment) to have --flavor take a comma-separated list of flavors, as in flutter build appbundle --flavor someFlavor,someOtherFlavor.

  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on May 20, 2023
  12. github-actions commented on Jun 3, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: releaseChallenges faced when attempting to productionize an appfound in release: 3.10Found to occur in 3.10found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on AndroidtoolAffects 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