Flutter: Firebase Analytics not compatible with null safety - flutter

I tried to move my project to the new Dart and make it null safety compatible but seems firebase_analytics is still not ready.
How can I bypass this error, are they going to release firebase_analytics null safety soon?
I filed an issue here: https://github.com/FirebaseExtended/flutterfire/discussions/5108
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
firebase_core: ^0.8.0-1.0.nullsafety.2
firebase_messaging: ^9.0.0-1.0.nullsafety.1
firebase_analytics: ^7.0.1
firebase_crashlytics: ^0.5.0-1.0.nullsafety.3
When I compile I get this error :
Because firebase_analytics >=7.0.1 depends on firebase_core ^0.7.0 and ketab depends on firebase_core ^0.8.0-1.0.nullsafety.2, firebase_analytics >=7.0.1 is forbidden.
So, because yourapp depends on firebase_analytics ^7.0.1, version solving failed.
pub get failed (1; So, because yourapp depends on firebase_analytics ^7.0.1, version solving failed.)

FlutterFire by the moment dont have null safety coverage for all of their packages
1 You can fork flutter fire repo https://github.com/FirebaseExtended/flutterfire
then you can play with versions in pubspec of firebase_analytics
then just use own version like that
firebase_analytics:
git:
url: HERE_YOUR_FORKED_REPO_URL
path: packages/firebase_analytics/firebase_analytics
2 I had familiar problem recently, just removed version at all and now its worked for me))
firebase_auth: ^0.21.0-1.0.nullsafety.0
cloud_firestore: 0.17.0-1.0.nullsafety.2
firebase_analytics:

Related

dependency issues why I try to run/debug my app

I'm new to making an app with flutter/dart and I'm running into some issues with the dependecies in the pubspec.yaml. I'm trying to make an app from a template to learn about how to work with repositories from github. After I brought in the code and repaired all the errors I tried to run/debug it and keep getting this from the output terminal:
Because google_sign_in >=5.4.0 depends on google_sign_in_platform_interface ^2.2.0 which depends on quiver ^3.0.0, google_sign_in >=5.4.0 requires quiver ^3.0.0.
And because cloud_firestore >=0.14.0-dev.1 <0.17.0-1.0.nullsafety.0 depends on quiver ^2.0.0, google_sign_in >=5.4.0 is incompatible with cloud_firestore >=0.14.0-dev.1 <0.17.0-1.0.nullsafety.0.
Because cloud_firestore >=0.13.3 <0.14.0-dev.1 depends on firebase_core ^0.4.4 and cloud_firestore >=0.11.0 <0.13.3 depends on firebase_core ^0.4.0, cloud_firestore >=0.11.0 <0.14.0-dev.1 requires firebase_core ^0.4.0.
Thus, if google_sign_in >=5.4.0 and cloud_firestore >=0.11.0 <0.17.0-1.0.nullsafety.0 then firebase_core ^0.4.0.
And because txapita depends on cloud_firestore >=0.11.0 <0.14.0+1, google_sign_in >=5.4.0 requires firebase_core ^0.4.0.
So, because txapita depends on both firebase_core ^2.4.1 and google_sign_in ^5.4.2, version solving failed.
pub get failed (1; So, because txapita depends on both firebase_core ^2.4.1 and google_sign_in ^5.4.2, version solving failed.)
exit code 1
Also, how do I get rid of txapita from the whole project if I can. It seems a lot of the code in the repository needs that package but I can't find the source package.
I've tried changing the versions to the versions in the error message
Here is my pubspec with things I've tried:
If I change the name to the name of the app it adds more errors to the output terminal when I save, is that how I get rid of the packages from the code?
name: txapita
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.2.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
## I've tried doing this with the version numbers
cloud_firestore: ">=0.11.0 <0.14.0+1"
cupertino_icons: null
firebase_auth: null
firebase_core: ^2.4.1
firebase_messaging: ^14.2.1
flutter_google_places: null
flutter_spinkit: ^4.1.2
geocoder: null
geoflutterfire: ^2.0.3+6
geolocator: null
google_maps_flutter: ^2.2.3
google_maps_webservice: null
http: null
location: null
modal_bottom_sheet: ^0.2.2
percent_indicator: ^2.1.7+2
provider: null
rxdart: any
shared_preferences: ^2.0.15
uuid: null
url_launcher: ^5.0.3
get_it: ^1.0.3+2
get: ^4.6.5
share_plus: ^6.3.0
google_sign_in: ^5.4.2
path_provider: ^2.0.11
path_provider_windows: ^2.1.3
shared_preferences_windows: ^2.1.2
path_provider_platform_interface: ^2.0.0
platform: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter:
uses-material-design: true
Rather than using null or any find the package version by searching the package.
Link to PUB: https://pub.dev/
E.g. : cloud_firestore: ^4.3.1
Try running flutter pub upgrade --major-versions

Flutter firebase - update packeges

I try to update firebase to nullsafe.
Here is my pubspec:
firebase_core: "^0.7.0"
firebase_auth: "^0.20.1"
firebase_crashlytics: "^0.4.0+1"
cloud_firestore: "^0.16.0+1"
cloud_functions: "^0.9.0"
firebase_storage: "^7.0.0"
firebase_messaging: "^8.0.0-dev.15"
firebase_remote_config: "^0.8.0-dev.0"
firebase_analytics: "^7.0.1"
firebase_database: "^6.0.0"
firebase_dynamic_links: "^0.7.0+1"
firebase_in_app_messaging: "^0.3.0+1"
firebase_performance: "^0.5.0+1"
But I can't do it because have an errors:
Because firebase_remote_config >=0.8.0-dev.0 <0.9.0-dev.0 depends on firebase_remote_config_platform_interface ^0.1.0-dev.0 which depends on firebase_core ^0.5.2, firebase_remote_config >=0.8.0-dev.0 <0.9.0-dev.0 requires firebase_core ^0.5.2.
So, because EMA depends on both firebase_core ^0.7.0 and firebase_remote_config ^0.8.0-dev.0, version solving failed.
Flutter Firebase dependency hell !!!
What to do?
Please show guaranteed working plugins firebase pluging(storage,auth,store,crashlitics)
You are getting version conflicts. You can solve them by letting pub find the version that is compatible with your other dependencies. Like this:
firebase_remote_config: any
If you get more of these errors, I suggest you to put all of packages to any then run flutter pub get and finally look in the pubspec.lock file and see what versions you got. Now you can put those versions in pubspec.yaml.

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.

Flutter 2.0 upgrade, pub get failed with nonsense dependency behavior

The project was working like a charm that started issues after the upgrade to flutter 2.0. following are errors upon pub get.
[delivered] flutter pub get
Running "flutter pub get" in delivering...
Because every version of flutter_localizations from sdk depends on intl 0.17.0 and firebase_auth_web >=0.3.0-dev.1 <0.4.0-1.0.nullsafety.0 depends on intl ^0.16.1, flutter_localizations from sdk is incompatible with firebase_auth_web >=0.3.0-dev.1 <0.4.0-1.0.nullsafety.0.
Because firebase_auth >=0.18.4 <=0.18.4 depends on firebase_auth_web ^0.3.2+2 and firebase_auth ^0.18.4+1 depends on firebase_auth_web ^0.3.2+3, firebase_auth ^0.18.4 requires firebase_auth_web ^0.3.2+2.
Thus, flutter_localizations from SDK are incompatible with firebase_auth ^0.18.4.
So, because iDelivered depends on both flutter_localizations any from SDK and firebase_auth ^0.18.4, version solving failed.
pub get failed (1; So, because delivered depends on both flutter_localizations any from SDK and firebase_auth ^0.18.4, version solving failed.)
exit code 1
Here is my pubspec.yaml for reference:
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
google_fonts: ^1.1.1
http: ^0.12.2
shared_preferences: ^0.5.12+4
firebase_core: ^0.5.3
firebase_auth: ^0.18.4
cloud_firestore: ^0.14.4
firebase_messaging: ^7.0.3
parse_server_sdk_flutter: ^2.1.0
place_picker: ^0.9.16
google_maps_flutter: ^1.0.6
animations: ^1.1.2
flutter_slidable: ^0.5.7
My suggestion is for a few week don't update your flutter version
To downgrade your flutter (Master channel):
flutter downgrade 1.22.6
Since you upgraded to Flutter 2.0, the flutter sdk is the source of the flutter_localizations. So, you have to upgrade your firebase dependencies e.g. firebase_auth, firebase_core to at least version 1.0.0.
My advice is that if the packages you are using have not been upgraded to null-safety OR they have not been recently updated, you should just stick to the 1.22.6 stable version of flutter for now.
You can try to add dependency_overrides to resolve this conflicts :
dependency_overrides:
intl: "<0.17.0"
Downgrade flutter using flutter downgrade version
my solution for this issue..
download both 2.0.2 flutter SDK and 1.22.6 flutter SDK. change flutter SDK project-wise.
In my app,
I upgrade following three pubs to latest
firebase_analytics: ^7.1.1,
firebase_core: ^1.0.1,
firebase_messaging: ^9.0.0
I downgrade google mobile ads SDK to 7.6.9 in IOS pod file, it works for me. https://github.com/FirebaseExtended/flutterfire/issues/4931

Shared preferences in flutter giving error on pub get

I started getting this error when adding shared preferences in a flutter app. It was working before and now I get
Because <app_name> depends on shared_preferences >=0.4.0 which requires Flutter SDK version >=0.1.4 <2.0.0, version solving failed.
pub upgrade failed (1; Because <app_name> depends on shared_preferences >=0.4.0 which requires Flutter SDK version >=0.1.4 <2.0.0, version solving failed.)
exit code 1
Here is the relevant part of my pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: "0.12.2"
progress_dialog: ^1.2.4
shared_preferences: ^0.5.12
I am new to flutter, and can't figure it out. I know that it was working before and it suddenly started giving this error.
It seems like your flutter sdk is not updated. You would have to update it by running this command in terminal/cmd:
flutter upgrade
Here's a guide on how to upgrade your flutter sdk version: https://flutter.dev/docs/development/tools/sdk/upgrading
It seems like you use an old package, which depends on shared_preferences: ^ 0.4.0 and sdk version lower than 2.0.0. Neither http nor progress_dialog depends on shared_preferences. If you don't use other packages in your app, let me know, because it is weird. Otherwise (if you use more packages that you listed in the question) just use dependency_overrides to override dependencies
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: "0.12.2"
progress_dialog: ^1.2.4
shared_preferences: ^0.5.12
dependency_overrides:
shared_preferences: ^0.5.12
had a similar problem, I changed the shared_preference to the latest version, as well as the path_provider obtained from the flutter pub site. that solved my issue