Why I can not add some packages to pubspec.yaml file?

1,061

This problem is due to your project's dependencies depending on other packages.

There is a conflict in their versioning which can be resolved, as per the documentation.

You can read about it here (Official Flutter Docs).

Share:
1,061
ygzkrmtc
Author by

ygzkrmtc

Updated on December 28, 2022

Comments

  • ygzkrmtc
    ygzkrmtc over 1 year

    When I try to add flutter_sound: ^7.7.0+1 to dependencies in pubspec.yaml and press to "pub get",,I recieve error message below, How can I solve this issue??

    pubspec.yaml

    name: lezzet_kitabi
    description: A new Flutter application.
    
    # The following line prevents the package from being accidentally published to
    # pub.dev using `pub publish`. This is preferred for private packages.
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev
    
    # The following defines the version and build number for your application.
    # A version number is three numbers separated by dots, like 1.2.43
    # followed by an optional build number separated by a +.
    # Both the version and the builder number may be overridden in flutter
    # build by specifying --build-name and --build-number, respectively.
    # In Android, build-name is used as versionName while build-number used as versionCode.
    # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
    # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
    # Read more about iOS versioning at
    # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.7.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
    
      # The following adds the Cupertino Icons font to your application.
      # Use with the CupertinoIcons class for iOS style icons.
      cupertino_icons: ^1.0.2
      bordered_text: ^1.0.1
      sqflite: ^1.3.0
      path_provider: ^1.6.27
      provider: ^4.3.3
      integration_test: ^1.0.2+2
      camera: 0.5.8+17
      image_picker: ^0.6.7+22
      path: ^1.8.0
      flutter_sound: ^7.7.0+1
    
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    
    # The following section is specific to Flutter.
    flutter:
    
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
    
      # To add assets to your application, add an assets section, like this:
      assets:
        - images/logoBGopacity.png
        - images/logoBG.png
        - images/cuttedlogo.PNG
        - images/sticker0.png
        - images/sticker1.png
        - images/sticker2.png
        - images/sticker3.png
        - images/sticker4.png
        - images/sticker5.png
        - images/sticker6.png
        - images/sticker7.png
        - images/sticker8.png
        - images/sticker9.png
        - images/sticker10.png
        - images/sticker11.png
        - images/sticker12.png
        - images/sticker13.png
        - images/sticker14.png
        - images/sticker15.png
        - images/sticker16.png
        - images/sticker17.png
        - images/sticker18.png
        - images/sticker19.png
        - images/sticker20.png
        - images/sticker21.png
        - images/sticker22.png
        - images/stickerForRecipeScreen.png
    
      fonts:
       - family: Marck
         fonts:
           - asset: fonts/MarckScript-Regular.ttf
       - family: Graduate
         fonts:
           - asset: fonts/Graduate-Regular.ttf
       - family: OpenSans
         fonts:
            - asset: fonts/OpenSansCondensed-Light.ttf
      #
      # For details regarding fonts from package dependencies,
      # see https://flutter.dev/custom-fonts/#from-packages
    
    

    Error

    Because flutter_sound >=6.4.3+42 depends on uuid ^2.2.2 which depends on crypto ^2.0.0, flutter_sound >=6.4.3+42 requires crypto ^2.0.0. And because every version of flutter_driver from sdk depends on crypto 3.0.0, flutter_sound >=6.4.3+42 is incompatible with flutter_driver from sdk. And because integration_test 1.0.2+2 depends on flutter_driver any from sdk and no versions of integration_test match >1.0.2+2 <2.0.0, flutter_sound >=6.4.3+42 is incompatible with integration_test ^1.0.2+2. So, because lezzet_kitabi depends on both integration_test ^1.0.2+2 and flutter_sound ^7.7.0+1, version solving failed. pub get failed (1; So, because lezzet_kitabi depends on both integration_test ^1.0.2+2 and flutter_sound ^7.7.0+1, version solving failed.)

    • Zaza.codes
      Zaza.codes about 3 years
      This just means some dependencies you are adding require higher or lower versions of some dependencies than what other packages that require thereby causing a conflict between these dependencies
    • Zaza.codes
      Zaza.codes about 3 years
      The best way to fix this is to override the dependencies which uses the best possible version those having conflicts or find an alternative dependency
    • Randal Schwartz
      Randal Schwartz about 3 years
      Or, copy the pubspec to a safe place, then take all the dependencies off (for "any version"), and see if it can come up with a solution. If not, you're likely not going to get anywhere making small tweaks. If it does work, and the tests pass (you do have tests, right?), you can copy the solution versions from the pubspec.lock file.
    • Randal Schwartz
      Randal Schwartz about 3 years
      Hmm. Tried that, got this: Because every version of bordered_text depends on flutter any from sdk which is forbidden, bordered_text is forbidden. So, because foo depends on bordered_text any, version solving failed. EDIT: oh weird, I just did pub dart get again, and it worked!
    • ygzkrmtc
      ygzkrmtc about 3 years
      What do you mean by testin sir ?
    • ygzkrmtc
      ygzkrmtc about 3 years
      I don't understand what I have to do I have stucked:/
    • ygzkrmtc
      ygzkrmtc about 3 years
      Also crypto package is written on the error but I don't have a package which is called crypto