问题
From the run terminal of android studio:
FAILURE: Build failed with an exception.
Where: Script 'C:\Flutter\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 362
What went wrong: A problem occurred configuring project ':cloud_firestore_web'.
Could not find method implementation() for arguments [project ':firebase_core'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
- 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.
Similar issue with firebase_auth.
回答1:
Had a similar problem recently, here are the steps that fixed it for me.
Run flutter pub upgrade to upgrade all the Firebase plugins to the latest versions.
Use the steps at https://firebase.flutter.dev/docs/migration to check for any deprecated code.
In the android/build.gradle file, make sure the google services dependency is
classpath 'com.google.gms:google-services:4.3.3'
or whatever the latest version is.In the android/app/build.gradle file, if you have any dependencies of the form
implementation 'com.google.firebase:[firebase-product:version-number]
then get rid of those linesRun flutter clean
来源:https://stackoverflow.com/questions/63595675/build-failing-with-an-exception-when-adding-firebase-auth-or-cloud-firestore-in