Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which version of Google Firebase plugin to use in Flutter app?

I've been stuck with Gradle not building (working on iOS fine). I struggled because Gradle was giving a generic error, finally got this today:

FAILURE: Build failed with an exception.

* What went wrong: Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[18.0.   0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.firebase:firebase-messaging:18.0.0 -> com.google.firebase:firebase-iid@[18.0.0], but fire   base-iid version was 17.1.2.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art   ifact with the issue.   -- Project 'app' depends on project 'firebase_messaging' which depends onto com.google.firebase:[email protected].   0  
-- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:[email protected]   -- Project 'app' depends on project 'firebase_analytics' which depends onto com.google.firebase:[email protected].   0   -- Project 'app' depends on project 'firebase_remote_config' which depends onto com.google.firebase:[email protected]   .1   -- Project 'app' depends onto com.google.firebase:[email protected]

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep   endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://   github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b   uild.gradle file.

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

This was after I took out the version numbers from my pubspec to see if that would help. I don't understand Google's version numbering and I'm not sure which versions of plugins I should be installing as it has caused conflicts in the past:

dependencies:
 flutter:
 sdk: flutter
 http:
 cached_network_image: 
 flutter_cache_manager:
 carousel_pro: 
 cloud_firestore:
 firebase_core:
 firebase_remote_config:
 dynamic_theme: 
 flutter_signin_button:
 shared_preferences:
 share:
 flutter_search_bar:
 google_sign_in:
 #flutter_facebook_login:
 flutter_html: 
 requests: 
 webview_flutter:
 flutter_webview_plugin:
 firebase_analytics:
 flutter_app_badger:  #for launcher badge icon (notifications)
 uuid:
 font_awesome_flutter: 
 device_info:
 carousel_slider: 
 flutter_spinkit: 
 flutter_typeahead:
 firebase_messaging:
 html_unescape:
 flutter_masked_text: 
 configurable_expansion_tile: 
 stripe_payment:
 square_in_app_payments:

Google doesn't seem to maintain consistent version numbering and by taking out the version numbers I thought it would at least take the latest version of the plugins which theoretically should work. So, how can I solve this?

like image 461
user10971950 Avatar asked Jun 02 '19 19:06

user10971950


People also ask

Is flutter Firebase compatible with iOS and Android?

Since Flutter is a multi-platform SDK, each FlutterFire plugin is applicable for both iOS and Android. So, if you add any FlutterFire plugin to your Flutter app, it will be used by both the iOS and Android versions of your Firebase app.

Where can I find the latest version of the flutterfire plugins?

This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com: FlutterFire is a set of Flutter plugins which connect your Flutter application to Firebase.

How do I get Firebase Analytics in flutter?

Run your Flutter app. Go to your app's Firebase project in the Firebase console, then click Analytics in the left-nav.

How to add Google services to flutter project?

Copy the SHA-1 key and navigate to the Firebase console, then go to the Project settings, and add the key as shown in the image below: Then download the google-services.json file again, and add it the project under android/app. After that execute flutter clean.


1 Answers

You should begin by putting the version number back in there.

This is an issue with firebase / play services versions being mismatched so you know for sure the other plugins in your pubspec.yaml are fine.

The dependancy which is failing is firebase messaging.

It's using many words to tell you

com.google.firebase:firebase-messaging:18.0.0 package depends on com.google.firebase:firebase-iid@[18.0.0]

but it's only finding 17.1.2.

You need

com.google.firebase:[email protected]
com.google.firebase:[email protected]
com.google.firebase:[email protected]

in the future, if you are having version issues check the specific packages GitHub issues to see if there's anything currently wrong with the version you're on. This will save you a lot of time.

I wouldn't recommend removing version numbers from your pubsepc.yaml but if you type

firebase_messaging: any

It will get a compatible version for you.

like image 66
Patrick Kelly Avatar answered Sep 19 '22 11:09

Patrick Kelly