[英]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).我一直坚持不构建 Gradle(在 iOS 上工作正常)。 I struggled because Gradle was giving a generic error, finally got this today:
我很挣扎,因为 Gradle 给出了一个通用错误,今天终于得到了这个:
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:firebase-messaging@18.0. 0
-- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:firebase-core@16.0.9 -- Project 'app' depends on project 'firebase_analytics' which depends onto com.google.firebase:firebase-analytics@16.5. 0 -- Project 'app' depends on project 'firebase_remote_config' which depends onto com.google.firebase:firebase-config@16.4 .1 -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
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.这是在我从 pubspec 中取出版本号以查看是否有帮助之后。 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?
那么,我该如何解决这个问题?
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.这是 firebase / play 服务版本不匹配的问题,因此您可以确定 pubspec.yaml 中的其他插件没问题。
The dependancy which is failing is firebase messaging.失败的依赖是 firebase 消息传递。
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.但它只找到 17.1.2。
You need你需要
com.google.firebase:firebase-core@16.0.9
com.google.firebase:firebase-analytics@16.5.0
com.google.firebase:firebase-config@16.4.1
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.将来,如果您遇到版本问题,请检查特定的包 GitHub 问题,看看您当前使用的版本是否有任何问题。 This will save you a lot of time.
这将为您节省大量时间。
I wouldn't recommend removing version numbers from your pubsepc.yaml but if you type我不建议从您的 pubsepc.yaml 中删除版本号,但如果您键入
firebase_messaging: any
It will get a compatible version for you.它将为您提供兼容版本。
The error you are getting is not necessarily from the packages you have listed in pubspec.yaml.您得到的错误不一定来自您在 pubspec.yaml 中列出的软件包。 It is referring to the dependencies on build.gradle.
它指的是对 build.gradle 的依赖。 Google has no issue with the version numbers.
谷歌对版本号没有问题。 There is a difference between the versions of packages ie what you have listed on pubspec.yaml and the dependencies on app/build.gradle.
包的版本(即您在 pubspec.yaml 上列出的版本)和 app/build.gradle 上的依赖项之间存在差异。 It would be wise to reconsider the number of packages you use as every package has a dependency and you may end up in a sticky situation where multiple packages are conflicting.
重新考虑你使用的包的数量是明智的,因为每个包都有一个依赖项,你可能最终会遇到多个包冲突的棘手情况。 In addition you end up with a bloated solution for minimal functionality.
此外,您最终会得到一个用于最少功能的臃肿解决方案。 Removing version numbers will not help as some packages are incompatible.
删除版本号无济于事,因为某些软件包不兼容。 I would suggest you start with the packages you require ie the firebase which from experience have no issues then incrementally add if necessary.
我建议您从您需要的软件包开始,即根据经验没有问题的 firebase,然后在必要时逐步添加。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.