Flutter integration_test package conflict with my code and cannot be resolved by tweaking package versions - so the whole app cannot run - flutter

I have an app (with null-safety), and want to use integration_test package to do some testing. The pubspec.yaml looks like:
dependencies:
archive: ^3.1.2
...
dev_dependencies:
build_resolvers: ^2.0.0
build_runner: ^1.11.5
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
...
Then it errors:
Because every version of flutter_driver from sdk depends on archive 2.0.13 and my_app depends on archive ^3.1.2, flutter_driver from sdk is forbidden.
I cannot use the non-null-safety version (2.x) of archive package, because if I do so, my app code will fail to run in null safety mode! I can accept that my tests run in non-null-safety mode, but I cannot tolerate my app code run in non-null-safety mode.
Thanks for any suggestions!

You need to override the archive package version to tell flutter_driver to use the latest one:
dev_dependencies:
build_resolvers: ^2.0.0
build_runner: ^1.11.5
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
dependency_overrides:
archive: ">=3.1.2"

Related

Could not find package flutter_localization in the Flutter SDK

I am currently trying to implement localization in my Flutter App but whenever I try to add the dependency for flutter_localization, I get the following error Message:
Because the timer depends on flutter_localization from SDK which doesn't exist (could not find package flutter_localization in the Flutter SDK), version solving failed.
I have also correctly added the path to both my flutter and dart SDKs in Android Studio.
Here is my pubspec.yaml file:
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
intl: ^0.17.0-nullsafety.2
cupertino_icons: ^1.0.2
sqflite: any
shared_preferences: ^2.0.15
path_provider: any
flutter_localization:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
I can't access GlobalMaterialLocalizations without flutter_localization and apparently, this is the easiest solution. I have already tried many solutions like checking version compatibilities and updating all dependencies. can you guys help me out?
Thanks in Advance!
Upgrading SDKs, Upgrading Dependencies, reinstalling flutter and Dart, and more
You misspelled the package
Replace
flutter_localization:
sdk: flutter
With
flutter_localizations:
sdk: flutter
Take note on the s on flutter_localizations

flutter packages get command gives an error error

hello I tried running flutter pub get and I was faced with this error:
flutter pub get
Waiting for another flutter command to release the startup lock...
Running "flutter pub get" in Deutsche-Flutter...
Because every version of flutter_test from sdk depends on test_api 0.3.0 and mockito 4.1.4 depends on test_api ^0.2.19-nullsafety, flutter_test from sdk is incompatible with mockito 4.1.4.
And because no versions of mockito match >4.1.4 <5.0.0, flutter_test from sdk is incompatible with mockito ^4.1.4.
So, because deutsche depends on both mockito ^4.1.4 and flutter_test any from sdk, version solving failed.
pub get failed (1; So, because deutsche depends on both mockito ^4.1.4 and flutter_test any from sdk, version solving failed.)
exit code 1
I already ran flutter upgrade and tried to run flutter pub get here are my dependencies:
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.0
flutter_svg: ^0.19.1
flutter_bloc: ^6.1.2
get: ^3.23.1
rxdart: ^0.19.0
http: ^0.12.2
google_fonts: ^0.3.9
circular_countdown_timer: ^0.1.0
pin_code_fields: ^2.4.0
google_nav_bar: ^3.2.0
line_icons: ^0.2.0
shared_preferences: ^0.5.12+4
flutter_launcher_icons: ^0.7.2+1
rive: ^0.6.8
timer_count_down: ^1.0.4+1
logger: ^0.9.4
dartz: ^0.9.0-dev.6
freezed_annotation: ^0.12.0
bloc_test: ^7.1.0
mockito: ^4.1.4
jwt_decode: ^0.3.1
carousel_slider: ^3.0.0
dev_dependencies:
build_runner:
freezed: ^0.12.7
flutter_test:
sdk: flutter
Update all of your plugins and that will work. And do make sure that all of them are null-safety enabled.
try replacing mokito version as any as follows.
mockito: any
then check the pubspeck.lock file and search mokito and take that version number from there and replace it in pubspec.yaml file
update the mockito package to => mockito: ^5.2.0

Every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5

I've been getting an error ever since I tried adding integration_test package along with get_test and it's primarily due to the fact that just_audio depends on crypto: ^3.0.0 while integration_test depends on crypto: ^2.1.5.
I tried to look online to see if it's possible to only install dependencies without dev_dependencies however it seems like flutter pub cli tool doesn't support that yet based on this issue.
Here is my pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
share: ^2.0.1
get:
get_storage:
shared_preferences: ^2.0.5
audio_service: 0.17.0-nullsafety.0
just_audio: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
get_test: ^3.13.3
integration_test: ^1.0.2+1
test: ^1.14.4
This is the error I am getting.
Because every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5, every version of integration_test requires crypto 2.1.5.
And because just_audio 0.7.4 depends on crypto ^3.0.0 and no versions of just_audio match >0.7.4 <0.8.0, integration_test is incompatible with just_audio ^0.7.4.
So, because egy_fm_radio depends on both just_audio ^0.7.4 and integration_test ^1.0.2+1, version solving failed.
pub get failed (1; So, because egy_fm_radio depends on both just_audio ^0.7.4 and integration_test ^1.0.2+1, version solving failed.)
I think this specific issue could have been be resolved by updating the Flutter SDK to the latest (>=2.2.0), but if there's anybody experiencing a similar issue, consider using Dependency overrides to override dependencies of built-in packages such as integration_test and flutter_driver.
dependency_overrides:
crypto: ^3.0.0
Note that this involves some risk and pub will show you a warning during dependency resolution.
Looking through your pubspec.yaml it appears the problem lies within the crypto dependency mismatch.
Inside your pubspec.yaml you can explictly declare the latest crypto version:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
share: ^2.0.1
crypto: 3.0.1
get:
get_storage:
shared_preferences: ^2.0.5
audio_service: 0.17.0-nullsafety.0
just_audio: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
get_test: ^3.13.3
integration_test: ^1.0.2+1
test: ^1.14.4
What happens is that when you use so many packages, some of those packages use some other packages. It may so happen that two or more packages use the same package.So, it creates an error incase of mismatch because you cannot have two different versions of the same package.

Flutter path_provider and sdk version mismatch

The current Dart SDK version is 2.10.5.
Because path_provider 2.0.1 requires SDK version >=2.12.0-259.9.beta <3.0.0 and no versions of path_provider match >2.0.1 <3.0.0, path_provider ^2.0.1 is forbidden.
So, because harmonoid depends on path_provider ^2.0.1, version solving failed.
pub get failed (1; So, because harmonoid depends on path_provider ^2.0.1, version solving failed.)
How do i solved this error? this is my pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.8.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
animations: ^1.1.2
provider: ^4.3.3
assets_audio_player:
git: https://github.com/alexmercerind/Flutter-AssetsAudioPlayer
media_metadata_retriever: ^0.0.2+1
http: ^0.12.2
path: ^1.7.0
path_provider: ^2.0.1
flutter_local_notifications: ^3.0.3
url_launcher: ^5.5.0
permission_handler: ^5.0.1+1
share: ^0.6.5+4
palette_generator: ^0.2.3
implicitly_animated_reorderable_list: ^0.3.2
dev_dependencies:
flutter_test:
sdk: flutter
error
My Dart SDK version is 2.12.0, and the Flutter version is 2.0.1. I created a new project and copied all your dependencies. The project worked without any problems.
For saving your time, I recommend upgrading to the stable channel and Flutter 2 using these commands or this link.
flutter channel stable
flutter upgrade
If you don't want to migrate your Flutter and Dard SDK versions yet,
I would recommend you to try and remove the version from the line:
path_provider: ^2.0.1
so it would look like this: path_provider:
run: pub get again
run your project again
Eventually I would recomment to migrate to the newest version of the SDKs and upgrade all your dependencies. This is just a temporary solution.

How to solve multi dependency version conflicts simply?

I have imported a project in android studio flutter. But, there is an incredible amount of version conflict coming in. If one solves other rises and if that goes down, other one rises. I am trying to get all packages and it is showing me the following error as below.
Because date_utils >=0.1.0+3 depends on intl ^0.16.0 and prokit_flutter depends on intl 0.17.0-nullsafety.2, date_utils >=0.1.0+3 is forbidden.
So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.
pub get failed (1; So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.)
Process finished with exit code 1
And my pubspec.yaml code is as below.
name: prokit_flutter
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
url_launcher: 5.0.3
nb_utils: 3.1.6+7
google_fonts: 1.1.0
animations: 1.1.2
intl: 0.17.0-nullsafety.2
http: 0.12.2
firebase_core: 0.5.0
firebase_analytics: 6.0.0
firebase_crashlytics: 0.1.4+1
google_sign_in: 4.5.3
html: 0.14.0+3
share: 0.6.5
mobx: ^1.2.1+2
flutter_mobx: ^1.1.0+2
flutter_statusbarcolor: 0.2.3
simple_animations: 1.3.8
snaplist: 0.1.8
flutter_svg: 0.18.1
flutter_slidable: 0.5.7
flutter_staggered_grid_view: 0.3.2
flutter_staggered_animations: 0.1.2
geolocator: 5.3.2+2
geocoder: 0.2.1
google_maps_flutter: 0.5.21+3
clustering_google_maps: 0.1.2
razorpay_flutter: 1.2.2
signature: 3.2.0
liquid_swipe: 1.5.0
lipsum: 1.0.1
flutter_colorpicker: 0.3.4
clippy_flutter: 1.1.1
flutter_tags: ^0.4.8
image_picker_gallery_camera: 0.1.6
video_player: 0.10.11+2
charts_flutter: ^0.9.0
like_button: ^1.0.1
flutter_reaction_button: ^1.0.1
lottie: ^0.6.0
showcaseview: ^0.1.6
date_utils: ^0.1.0+3
cached_network_image: ^2.3.1
flutter_localizations:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
mobx_codegen:
build_runner: ^1.9.0
#flutter packages pub run build_runner build
flutter:
uses-material-design: true
assets:
- images/smartDeck/images/
fonts:
- family: Andina
fonts:
- asset: fonts/andina.ttf
And there are 4-5 dependency version error. How can I solve this version error thing in one click or I can just somehow skip this version problem and get the thing done. Please help, Thanks in Advance.
Whenever conflicts between dependencies occur, the simplest solution is to just remove the version number of both that dependencies and type 'any' without quotes in front of them.
for example let's say this following two dependency conflicts:
shared_preferences: ^0.5.7+3
requests: ^3.3.0
then do following:
shared_preferences: any
requests: any
After this do pub get and issue will be resolved. Now, most importantly, don't leave any dependency on this form. instead goto pubspec.lock file and search these two dependencies. Flutter itself chooses the versions that don't conflict, copy those and replace it to pubsec.yaml
You can use dependency_overrides in your pubspec.yaml to force a specific package version. The package version will override any reference to a dependency in the entire app.
In your case you could use
dependencies:
flutter:
sdk: flutter
...
cupertino_icons: ^1.0.0
dependency_overrides:
intl: ^0.17.0-nullsafety.2
See dependency_overrides for more information.
Replace intl: 0.17.0-nullsafety.2 version with intl: 0.16.1 and remove intl from dependency overrides.
Now, run pub get command.
You can simply change the version of package that is causing conflic with another version which is compatible with your dart SDK. I tried it and the problem was solved.
had the same problem; ran the following command:
flutter pub upgrade --major-versions
if you don't mind having the latest version of all the dependencies while solving version conflict issues, this should be a quick fix.
I had this problem after resetting my Mac mini.
If you still have the pubspec.lock file at the last successful run (or get it from another dev, on that dev's computer the project is still running).
flutter clean.
Replace pubspec.lock by the old one.
Run the project again.