Error: because example depends on package/project from hosted on [URL], version solving failed.)

Viewed 602

I had an error in project fluter and I don't know how to fix that. this error occurs when I command flutter pub get run

Error:


SLVR:   derived: json_annotation ^4.4.0
SLVR:   conflict: package_base 1.22.025+9 depends on package_context ^1.21.353+4
SLVR:   ! package_base 1.22.025+9 is partially satisfied by not package_base >1.22.025+9 <2.0.0
SLVR:   ! which is caused by "no versions of package_base match >1.22.025+9 <2.0.0"
SLVR:   ! thus: package_base ^1.22.025+9 requires package_context ^1.21.353+4
SLVR:   ! package_base ^1.22.025+9 is satisfied by package_base ^1.22.025+9
SLVR:   ! which is caused by "package_identity depends on package_base ^1.22.025+9"
SLVR:   ! thus: package_context ^1.21.353+4 is required
SLVR:   ! not package_context ^1.21.353+4 is satisfied by package_context ^1.21.353+4
SLVR:   ! which is caused by "package_identity depends on package_context ^1.21.353+4"
SLVR:   ! thus: version solving failed
SLVR: Version solving took 0:00:04.357063 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (4.4s).
ERR : Because package_base 1.22.025+9 depends on package_context ^1.21.353+4 and no versions of package_base match >1.22.025+9 <2.0.0, package_base ^1.22.025+9 requires package_context from hosted on http://2.1.2.9:500/[token]/.
    | So, because package_identity depends on both package_base ^1.22.025+9 and package_context from hosted on http://2.1.2.9:500/[token]/, version solving failed.
FINE: Exception type: SolveFailure
FINE: package:pub/src/solver/version_solver.dart 312:5                 VersionSolver._resolveConflict
    | package:pub/src/solver/version_solver.dart 133:27                VersionSolver._propagate
    | package:pub/src/solver/version_solver.dart 97:11                 VersionSolver.solve.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                                       Future.catchError
    | package:pub/src/utils.dart 109:52                                captureErrors.wrappedCallback
    | package:stack_trace                                              Chain.capture
    | package:pub/src/utils.dart 122:11                                captureErrors
    | package:pub/src/command.dart 180:13                              PubCommand.run
    | package:args/command_runner.dart 209:27                          CommandRunner.runCommand
    | package:pub/src/command_runner.dart 173:24                       PubCommandRunner.runCommand
    | package:pub/src/command_runner.dart 158:20                       PubCommandRunner.run
    | package:dartdev/dartdev.dart 45:56                               runDartdev
    | C:\b\s\w\ir\cache\builder\sdk\pkg\dartdev\bin\dartdev.dart 11:9  main
---- End log transcript ----
pub get failed (1; ---- End log transcript ----)
Result Attachments will be stored in LogStore
Run Attachments will be stored in LogStore
No Result Found to Publish 'D:\a\1\s\junit.xml'.
##[error]Some tests failed

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 10.0.19044.1466], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[!] Android Studio (version 4.1)
    X Unable to determine bundled Java version.
[√] VS Code (version 1.63.2)
[√] Connected device (2 available)

! Doctor found issues in 2 categories.
1 Answers

I know you are waiting for a solution, here it is:

Solution 1: The simplest solution if you are doing some important and deadline work and you don't want to take any risk, you can use an older version of Flutter only. If you have already upgraded Flutter 2, You can downgrade the older version using flutter downgrade Note: Must try everything on new or older Flutter after taking a backup of your project.

Solution 2:

If you are just learning and not doing any deadline work then you can try this option because it's all about trial-n-error.

Use a new section in pubspec.yaml named dependency_overrides: Documentation

You can use dependency_overrides to temporarily override all references to a dependency.

Here is the older version of my pubspec.yaml which is working before upgrading Flutter 2. I got the errors in as it is pubspec after upgrading Flutter 2. After trying for 2 days I got a solution using dependency_overrides. And finally here is the new pubspec.yaml, In which you can check some dependency added to dependency_overrides.

How to do it:

You can check which dependency is dependent on another dependency. You can write that dependency in dependency_overrides:

dependency_overrides:
  firebase_auth: “>=1.0.0”
  firebase_core: “>=0.7.0”
  firebase_messaging: “>=8.0.0-dev.14”
  firebase_remote_config: “>=0.6.0”
  firebase_auth_web: “>=0.2.0” 
  firebase: “>=7.0.0”
  flutter_local_notifications: “>=4.0.0”

As of now, At the time of writing this blog, It is working for me, you can change version changes as per your needs.

Warning: Using a dependency override involves some risk. For example, using an override to specify a version outside the range that the package claims to support, or using an override to specify a local copy of a package that has unexpected behaviors, may break your application.

Hopefully, someone will get help or clue from it. If you have any questions, free feel to ping me any time.

refresnce: https://pratikbutani.medium.com/flutter-2-upgrade-flutter-version-solving-failed-error-33ac1087cb6b

Related