Because every version of flutter_test from sdk depends on... flutter_test from sdk is forbidden, version solving failed
Asked Answered
E

15

71

I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?

enter image description here

Erotic answered 1/11, 2018 at 7:27 Comment(1)
Have you checked this articlePsychomancy
A
57

If you get the message:

Because every version of flutter_test from sdk depends on...

It means flutter_test depends on a dependency with version lower than you specified in another dependency.

To solve this, open pubspec.yaml, and remove the version number of the problem dependency:

Example:

Change

  archive: ^2.0.13 --> remove this number

To:

  archive: 
Audly answered 23/4, 2020 at 18:33 Comment(4)
How to upgrade the flutter_test?Fere
use flutter upgradeWende
Is this recommended solution? As far as I know omitting dependency version is discouragedIntertidal
this solution works, but is it possible to degreade the versions for the dependency needed by fluttr_test?Torment
M
17

You have provided or trying to use http: ^0.12.0 dependency on implementing API calls in pubspec.yaml file but flutter_test will require http: ^0.11.3+17. That's why it fails. Please replace

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0

with

dependencies:
  flutter:
    sdk: flutter
  http: ^0.11.3

Hope it will help you out.

Monda answered 12/11, 2018 at 8:31 Comment(0)
W
9

I encountered this error when trying to update the collection package.

My error:

Because butler_labs depends on flutter from sdk which depends on collection 1.17.1, collection 1.17.1 is required.
So, because butler_labs depends on collection ^1.17.2, version solving failed.

The solution was to run flutter update-packages --force-upgrade which updated the dependencies in my local instance of Flutter. This command is mentioned in the official docs.

Wellspring answered 5/7, 2023 at 18:51 Comment(0)
F
6

I was facing a similar error. I solved it by removing all the version numbers from the dependencies: section in pubspec.yaml.

So, if my pubspec.yaml looked like this before:

dependencies:
  freezed_annotation: ^0.14.3

I changed it to this:

dependencies:
  freezed_annotation:

I'm assuming this fetches the latest "possible" version of each package.

Frech answered 1/9, 2021 at 13:28 Comment(1)
This answer is the same as (or very similar to) this one. It would be better to upvote that answer instead of posting it again. Invest some time in the site and you will gain sufficient privileges to upvote answers that helped you.Wendywendye
H
3

In my case, I somehow deleted sdk: flutter:

dependencies:
  flutter:
    sdk: flutter
Holler answered 13/3, 2021 at 4:9 Comment(2)
What does sdk: flutter mean?Offing
@Offing Flutter is a library and sdk: flutter specifies dart to mount it. without it, you will not be able to run a flutter project.Digestif
L
2

In my case IDE referred to an an older version of dart because of fvm. Seems like 'run' button called fvm flutter run, but not flutter run as I expected. After I deleted fvm folder from the project the problem has gone.

Leges answered 22/11, 2021 at 12:59 Comment(0)
E
2

Try to change the dependency version that you were added in your pubspec.yaml file don't use the current or latest version try some previous versions of dependency.

for ex - if you are using latest sqflite version then chnage to previous version of that and then re-run your whole project.

Encamp answered 22/6, 2022 at 8:36 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewBoa
C
1

Can you please provide the dependencies in your pubspec.yaml? It looks like your app depends on at least http 0.12.0 but flutter_test specifically requires http 0.11.3+17 (an older version) which makes it fail.

Chrysoberyl answered 1/11, 2018 at 7:43 Comment(1)
I wanted to have the latest version of http dependency but it looks like flutter current beta version doesn't support it so I removed the version constraint and it stopped giving me the error and added the dependency.Erotic
W
1

If your app doesn't have too many dependencies that could broke, you can try to upgrade your Flutter version: flutter upgrade. It most probably will fix this problem. But always be sure to understand that your app might break at unexpected places. So you're fine if:

  • either you're doing it for small app
  • or it's big app at work and it has extensive tests that will tell you something has broken
  • if big app without tests, be sure to test every important place of the app, where dependencies are being used
Wheelchair answered 2/11, 2021 at 11:31 Comment(0)
E
1

Let's say the matcher package has encountered the following issue, which is the real case I suffered in the past:

Because matcher >=0.12.15 depends on test_api ^0.5.0 and every version of flutter_test from sdk depends on test_api 0.4.16, matcher >=0.12.15 is incompatible with flutter_test from sdk.
So, because myapp depends on both flutter_test from sdk and matcher ^0.12.15, version solving failed.

Simply run three commands subsequently:

flutter pub remove matcher
flutter pub add --dev matcher

flutter pub get

Finally there is a line change in pubspec.yaml:

# before
  matcher: ^0.12.15

# after
  matcher: ^0.12.13

And myapp can be run successfully using the above solution to upgrade flutter in channel stable, and upgrade flutter pub packages:

# upgrade flutter in channel stable
flutter channel stable
flutter upgrade

# upgrade flutter pub packages
flutter pub outdated
flutter pub upgrade
Eda answered 17/4, 2023 at 10:52 Comment(0)
S
1

Because flutter_cab depends on flutter_google_places_hoc081098 ^1.2.0 which depends on http ^0.13.4, http ^0.13.4 is required. So, because flutter_cab depends on http ^1.2.0, version solving failed. I am facing this issue

Stinkhorn answered 23/1, 2024 at 11:44 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Indigence
W
0

Change depending attributes version inside pubspec.yaml if it says depands on http *** than change http version or if it says depands on collection *** than change collection version.

Waldron answered 13/6, 2022 at 15:50 Comment(0)
H
0

run flutter upgrade. This problem occurs because your library is using the SDK version.

Hallucinatory answered 16/1, 2024 at 21:4 Comment(0)
A
0

Remove the Flutter package clear installation cache and then install the Flutter package.

Anorthic answered 15/4, 2024 at 10:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Indigence
Y
0

change in pubspect.yaml your http package:

dependencies:
  flutter:
    sdk: flutter
  ...
  http: 0.12.0

to :

dependencies:
  flutter:
    sdk: flutter
  ...
  http: any
Yep answered 2/7, 2024 at 9:22 Comment(1)
Not a good standard practice. Will cause more problems down the line.Obie

© 2022 - 2025 — McMap. All rights reserved.