60

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

Community
  • 1
  • 1
Shoaib Nomani
  • 601
  • 1
  • 5
  • 4
  • Have you checked [this article](https://pratikbutani.medium.com/flutter-2-upgrade-flutter-version-solving-failed-error-33ac1087cb6b) – Pratik Butani Mar 13 '21 at 12:21

11 Answers11

53

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: 
live-love
  • 48,840
  • 22
  • 240
  • 204
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.

Rahul Sharma
  • 12,515
  • 6
  • 21
  • 30
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.

spyk3x
  • 61
  • 1
  • 3
  • 5
    This answer is the same as (or very similar to) [this one](https://stackoverflow.com/a/61394530/8517948). 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](//stackoverflow.com/privileges) to upvote answers that helped you. – LW001 Sep 01 '21 at 20:05
3

In my case, I somehow deleted sdk: flutter:

dependencies:
  flutter:
    sdk: flutter
Hai nguyen thanh
  • 718
  • 7
  • 17
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.

Oleksandr
  • 1,396
  • 1
  • 8
  • 14
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.

  • 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 Review](/review/late-answers/32077882) – Sagar Jun 29 '22 at 06:47
2

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.

Code on the Rocks
  • 11,488
  • 3
  • 53
  • 61
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.

flarkmarup
  • 5,129
  • 3
  • 24
  • 25
  • 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. – Shoaib Nomani Nov 06 '18 at 08:15
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
Konstantin Kozirev
  • 944
  • 1
  • 10
  • 23
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.

Prudvangar
  • 25
  • 3
0

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
mondayrris
  • 539
  • 4
  • 13