当我尝试在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
字符串
2条答案
按热度按时间swvgeqrz1#
此问题是由于最近对
firebase_auth
包的更新(特别是版本4.13.0)引起的命名冲突造成的,该版本现在导出AuthProvider
类。此更改在this pull request中引入,并在2023年11月9日的release notes中提到。Shahed Emon在上面的评论中指出了可能的修复方法:
AuthProvider
类以避免冲突,或者...firebase_auth
包导入冲突类时使用别名,如下所示:字符串
通过在导入
firebase_auth
包时使用别名,可以防止该包中的AuthProvider
被无意中合并到现有代码中,这些代码没有引用firebase_auth
的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”导入的。
1zmg4dgp2#
强制使用
4.12.0
版本对我来说很有效:字符串
正如@lukenntt提到的,
firebase_auth
版本4.13.0
似乎引入了冲突。在某些情况下,使用hide
或别名似乎不够。