Skip to content

package assets declared under dev_dependency shouldn't be included in release bundle #79261

Closed

Description

@rh-id

Steps to Reproduce

See example project https://github.com/rh-id/example_dev_dependency_fi for the steps

Expected results: Flutter should ignore package assets declared under dev_dependency on release bundle / version

Actual results: Flutter include the package assets declared under dev_dependency on release bundle / version

Logs
[✓] Flutter (Channel stable, 2.0.2, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.2 at /home/rubyh/Flutter/flutter
    • Framework revision 8962f6dc68 (3 weeks ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/rubyh/Android/Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /home/rubyh/Android/Sdk
    • ANDROID_SDK_ROOT = /home/rubyh/Android/Sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
    • All Android licenses accepted.

Related Issues:

Do not create plugins from dev_dependencies #56591
Don't include dev_dependencies in native build scripts #45714
integration_test embedded in shipping iOS apps when added to pubspec #74274

Activity

  1. pedromassangocode commented on Mar 29, 2021

    @pedromassangocode

    After reading this StackOverflow and https://dart.dev/tools/pub/dependencies#dev-dependencies I'm considering this as proposal as there is not documentation saying that assets from dev dependencies will not be included into the final app bundle.

    If you have any reference about that please share the link.
    Thank you

  2. added
    a: assetsPackaging, accessing, or using assets
    a: releaseChallenges faced when attempting to productionize an app
    a: sizeReducing IPA/APK/JS sizes
    platform-androidAndroid applications specifically
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Mar 29, 2021
  3. rh-id commented on Mar 29, 2021

    @rh-id
    Author

    Hi, @pedromassangocode I'm not sure why it is a proposal not a bug, if the reason to label this as proposal was documentation,
    so far I didn't find any flutter documentation saying anything on how dev_dependencies behave with final app bundle as well. by that reasoning dev_dependencies shouldn't work with flutter at all.

    If flutter follows dart documentation on dev_dependencies which means ignoring the package on the final app bundle, then flutter should ignore the assets declared as well.

  4. rh-id commented on Apr 6, 2021

    @rh-id
    Author

    hi @pedromassangocode Additional findings:

    When adding integration_test package to dev_dependencies, GeneratedPluginRegistrant class generate the integration test class as well.

    pubspec.yaml

    dev_dependencies:
      flutter_test:
        sdk: flutter
      another_package:
        path: another_package
      integration_test:
        sdk: flutter
    
    public final class GeneratedPluginRegistrant {
      public static void registerWith(@NonNull FlutterEngine flutterEngine) {
        flutterEngine.getPlugins().add(new dev.flutter.plugins.integration_test.IntegrationTestPlugin());
      }
    }
    

    after checking classes.dex in my release bundle, the IntegrationTestPlugin is included, so basically everything under dev_dependencies is included in the release bundle? I'm not sure how to check if the dart code is included in the release bundle. since there is no documentation mentioning this does it mean it is as per existing behavior? so including integration test in the final release bundle is normal ?

  5. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: buildBuilding flutter applications with the tool
    P3Issues that are less important to the Flutter project
    and removed
    platform-androidAndroid applications specifically
    on Aug 30, 2022
  6. 1 remaining item

  7. blackmenthor commented on Apr 19, 2023

    @blackmenthor

    Up for this issue (sorry for not just reacting), but one use-case that might be quite annoying is: say you have an assets that are only meant to be shipped during development and you don't want that to be included in the release bundle, it won't be possible until some exclusion of assets for production build is done.

    Right now there's couple of solution that might work (e.g. using script that deletes some dependency or assets during flutter build, but I'd have to admit that's not pretty.

  8. like-clockwork commented on Aug 20, 2023

    @like-clockwork

    I'm here because I just discovered that in one of my projects I've been placing essential package references under 'dev_dependencies' this whole time - and yet, my release builds have been running flawlessly. I figure it might have something to do with this

  9. chandrabezzo commented on Sep 13, 2023

    @chandrabezzo

    Just curious is there a plugin/package on dev_dependencies that contains large enough assets? Because I have never found a plugin/package that has very large assets on dev_dependencies 🤔

  10. MeandNi commented on Apr 15, 2024

    @MeandNi
    Contributor

    Just curious is there a plugin/package on dev_dependencies that contains large enough assets? Because I have never found a plugin/package that has very large assets on dev_dependencies 🤔↳

    Sometimes we want to use certain resources only under debug.

  11. rh-id commented on Apr 28, 2024

    @rh-id
    Author

    Hi all, adding related issues above. It seemed to occur on other platforms

  12. zhujiageng commented on Oct 28, 2024

    @zhujiageng

    any update?

  13. taltap-jake commented on Dec 19, 2024

    @taltap-jake

    We were affected by this issue today. The inclusion of integration_test in dev_dependencies caused a crash in our release build. Very unintuitive, as dev_dependencies was far from the first place we went looking for the cause of a crash in the release build.

    As it seems this is actually the way flutter behaves - we basically have no option but to inject the integration test dependencies into the pubspec.yaml as part of the runner script launching the tests. Not optimal.

  14. github-actions commented on Jun 2, 2025

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

  15. locked as resolved and limited conversation to collaborators on Jun 2, 2025
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

    P3Issues that are less important to the Flutter projecta: assetsPackaging, accessing, or using assetsa: buildBuilding flutter applications with the toola: releaseChallenges faced when attempting to productionize an appa: sizeReducing IPA/APK/JS sizesc: proposalA detailed proposal for a change to Flutterteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions