Azg*_*aou 5 build gradle flutter
当我尝试在 Android Studio 中运行 flutter 代码时,出现以下错误:
Task :app:compileFlutterBuildDebug
lib/features/auth/authRepository.dart:5:1: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
import 'package:flutterquiz/features/auth/cubits/authCubit.dart';
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:7:1: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
import 'package:flutterquiz/features/auth/cubits/authCubit.dart';
^^^^^^^^^^^^
lib/features/auth/cubits/signInCubit.dart:6:1: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
import 'authCubit.dart';
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:62:27: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
if (authProvider == AuthProvider.email) {
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:136:15: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
signOut(AuthProvider.email);
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:159:21: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
if (provider == AuthProvider.fb) {
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:161:28: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (provider == AuthProvider.gmail) {
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:163:28: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (provider == AuthProvider.mobile) {
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:165:28: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (provider == AuthProvider.apple) {
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:199:15: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
signOut(AuthProvider.mobile);
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:207:22: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider = AuthProvider.fb;
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:209:22: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider = AuthProvider.gmail;
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:211:22: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider = AuthProvider.mobile;
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:213:22: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider = AuthProvider.apple;
^^^^^^^^^^^^
lib/features/auth/authRepository.dart:215:22: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider = AuthProvider.email;
^^^^^^^^^^^^
lib/ui/screens/auth/otp_screen.dart:385:23: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
AuthProvider.mobile,
^^^^^^^^^^^^
lib/ui/screens/auth/otp_screen.dart:398:31: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
authProvider: AuthProvider.mobile,
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:167:27: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
if (authProvider == AuthProvider.gmail) {
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:172:34: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (authProvider == AuthProvider.mobile) {
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:178:34: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (authProvider == AuthProvider.email) {
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:184:34: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
} else if (authProvider == AuthProvider.apple) {
^^^^^^^^^^^^
lib/features/auth/authRemoteDataSource.dart:294:25: Error: 'AuthProvider' is imported from both 'package:firebase_auth_platform_interface/src/auth_provider.dart' and 'package:flutterquiz/features/auth/cubits/authCubit.dart'.
if (authProvider == AuthProvider.gmail) {
^^^^^^^^^^^^
Target kernel_snapshot failed: Exception
Task :app:compileFlutterBuildDebug FAILED
Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/macbook/development/flutter/bin/flutter'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)
此问题是由于最近更新包firebase_auth(特别是版本 4.13.0,现在导出一个AuthProvider类)而引起的命名冲突。此更改在此拉取请求中引入,并在 2023 年 11 月 9 日的发行说明中提到。
Shahed Emon 在上面的评论中指出了可能的修复方法:
AuthProvider类以避免冲突,或者......firebase_auth,如下所示:import 'package:firebase_auth_platform_interface/src/auth_provider.dart' as firebase;
Run Code Online (Sandbox Code Playgroud)
通过在导入firebase_auth包时使用别名,您可以防止AuthProvider该包中的 无意中合并到不引用firebase_auth's的现有代码中AuthProvider。
作为参考,这是我收到的错误:
无法构建 iOS 应用程序
无法为设备构建预编译应用程序。
错误(Xcode):lib/feature/auth/provider/firebase_auth_provider.dart:3:1:错误:“AuthProvider”是从“package:app/feature/auth/provider/auth_provider.dart”和“package:firebase_auth_platform_interface”导入的/src/auth_provider.dart'。
| 归档时间: |
|
| 查看次数: |
906 次 |
| 最近记录: |