英文:
Flutter firebase_auth and firebase_core depency errors
问题
我正在尝试在将Flutter SDK更新到最新的3.10版本后运行我的旧项目,但我遇到了这个错误。
我的pubspec.yaml
文件有以下依赖项:
dependencies:
firebase_auth:
firebase_core:
intl: ^0.18.1
flutter_spinkit: ^5.1.0
web_socket_channel: ^2.0.0
flutter_native_splash: ^2.2.18
firebase_database:
fluttertoast: ^8.0.7
shared_preferences: ^2.0.8 # 添加这一行
url_launcher: ^6.0.0
http: ^1.0.0
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_launcher_icons: ^0.13.1
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
dependency_overrides:
firebase_core_platform_interface: 4.5.1
运行flutter doctor
不显示问题。
这是我遇到的错误消息:
../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-2.13.0/lib/src/firebase_app.dart:18:25: 错误:找不到成员:'FirebaseAppPlatform.verify'。
FirebaseAppPlatform.verify(_delegate);
^^^^^^
目标kernel_snapshot失败:异常FAILURE:构建失败。
在哪里:
脚本 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' 第1201行出了什么问题:
任务':app:compileFlutterBuildDebug'执行失败。
进程'command 'C:\src\flutter\bin\flutter.bat''以非零退出值1结束。尝试:\
- 使用--stacktrace选项运行以获取堆栈跟踪。\
- 使用--info或--debug选项运行以获取更多日志输出。\
- 使用--scan运行以获取完整的洞察。
获取更多帮助,请访问 https://help.gradle.org。
BUILD FAILED in 40s
异常:Gradle任务assembleDebug以退出代码1失败。
我尝试运行了flutter upgrade
,但也没有起作用。
英文:
I am trying to run my old project after updating flutter sdk to the latest 3.10, but I am getting this error
my pubspec.yaml has the following dependencies
dependencies:
firebase_auth:
firebase_core:
intl: ^0.18.1
flutter_spinkit: ^5.1.0
web_socket_channel: ^2.0.0
flutter_native_splash: ^2.2.18
firebase_database:
fluttertoast: ^8.0.7
shared_preferences: ^2.0.8 # Add this line
url_launcher: ^6.0.0
http: ^1.0.0
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.2
dev_dependencies:
flutter_launcher_icons: ^0.13.1
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
dependency_overrides:
firebase_core_platform_interface: 4.5.1
Running flutter doctor
shows no issues.
This is the error message I'm getting:
> ../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-2.13.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verify'.
>
> FirebaseAppPlatform.verify(_delegate);
> ^^^^^^
> Target kernel_snapshot failed: Exception
>
>
> FAILURE: Build failed with an exception.
>
> * Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1201
>
> * What went wrong:
> Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
>
> * 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
>
> BUILD FAILED in 40s
> Exception: Gradle task assembleDebug failed with exit code 1
I have tried running flutter upgrade but its not working as well.
答案1
得分: 0
找到了修复方法
首先,确保所有依赖项的版本未指定。然后运行
flutter pub get
之后尝试运行项目,应该会抛出一个 fullthroughError
在此错误被抛出后,打开 action_code_info.dart 并编辑 'ActionCodeInfo'
它应该看起来像这样
ActionCodeInfoOperation get operation {
switch (_operation) {
case 0:
return ActionCodeInfoOperation.unknown;
case 1:
return ActionCodeInfoOperation.passwordReset;
case 2:
return ActionCodeInfoOperation.verifyEmail;
case 3:
return ActionCodeInfoOperation.recoverEmail;
case 4:
return ActionCodeInfoOperation.emailSignIn;
case 5:
return ActionCodeInfoOperation.verifyAndChangeEmail;
case 6:
return ActionCodeInfoOperation.revertSecondFactorAddition;
default:
throw Exception(); // or throw UnsupportedError('FallThroughError');
}
}
Dart 之所以抛出该错误是因为 FallThroughError 未定义,所以通过编辑这个与包一起提供的文件,我成功修复了运行时错误并运行了代码。
希望这真的能帮助到某人。
英文:
Found a way to fix it
firstly, make sure all dependencies' versions are not specified. Then run
flutter pub get
after this try to run the project and it should through a fullthroughError
after this error has been thrown, open the action_code_info.dart and edit the 'ActionCodeInfo'
it should look something like this
ActionCodeInfoOperation get operation {
switch (_operation) {
case 0:
return ActionCodeInfoOperation.unknown;
case 1:
return ActionCodeInfoOperation.passwordReset;
case 2:
return ActionCodeInfoOperation.verifyEmail;
case 3:
return ActionCodeInfoOperation.recoverEmail;
case 4:
return ActionCodeInfoOperation.emailSignIn;
case 5:
return ActionCodeInfoOperation.verifyAndChangeEmail;
case 6:
return ActionCodeInfoOperation.revertSecondFactorAddition;
default:
throw Exception(); // or throw UnsupportedError('FallThroughError');
}
}
Dart was throwing that error because FallThroughError was not defined, so by editing this file that comes with the package I managed to fix the runtime error and run the code
Hope this really helps someone.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论