【问题标题】:How to fix the firebase error I get after importing firebase auth in my dart file in flutter app?如何修复在颤振应用程序的 dart 文件中导入 firebase auth 后出现的 firebase 错误?
【发布时间】:2021-03-24 23:06:15
【问题描述】:

我已经面临这个错误好几个星期了,我根本无法在我的应用程序中使用 firebase。我创建了一个新应用程序,然后根据需要添加了 firebase。我立即在我的应用程序中导入 firebase auth,我得到了一堆错误。我已经厌倦了创建几个应用程序并向其添加了 firebase,但仍然出现此错误。 跟着教程没用

这是我的 pubspec.yaml 文件

dependencies:
  flutter:
    sdk: flutter
  firebase_core: "^0.5.3"
  firebase_auth: "^0.18.4"
  cloud_firestore: "^0.14.4"

我的飞镖文件

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';

class AuthService {
  static final _auth = FirebaseAuth.instance;
  static final _fireStore = FirebaseFirestore.instance;

  static Future<bool> signUp(String name, String email, String password) async {
    try {
      UserCredential authResult = await _auth.createUserWithEmailAndPassword(
          email: email, password: password);

      User signedInUser = authResult.user;

      if (signedInUser != null) {
        _fireStore.collection('users').doc(signedInUser.uid).set({
          'name': name,
          'email': email,
          'profilePicture': '',
          'coverImage': '',
          'bio': ''
        });
        return true;
      }

      return false;
    } catch (e) {
      print(e);
      return false;
    }
  }

}

运行中的错误消息 错误消息很长,每次分解时都一样 开始

/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/firebase_auth.dart:10:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.1.4/lib/firebase_auth_platform_interface.dart': The system cannot find the path specified.

import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
       ^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/firebase_auth.dart:15:1: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.1.4/lib/firebase_auth_platform_interface.dart': The system cannot find the path specified.

export 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart'
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:15:3: Error: Type 'FirebaseAuthPlatform' not found.
  FirebaseAuthPlatform _delegatePackingProperty;
  ^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:21:3: Error: Type 'FirebaseAuthPlatform' not found.
  FirebaseAuthPlatform get _delegate {
  ^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:137:10: Error: Type 'ActionCodeInfo' not found.
  Future<ActionCodeInfo> checkActionCode(String code) {
         ^^^^^^^^^^^^^^

关闭

    RecaptchaVerifierOnExpired onExpired,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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 5m 25s
Exception: Gradle task assembleDebug failed with exit code 1

【问题讨论】:

  • 你试过运行flutter clean吗?
  • 是的,我运行了 flutter pub get

标签: firebase flutter firebase-authentication flutter-android


【解决方案1】:

添加新包后必须在终端中运行flutter pub get 并重新启动项目。

【讨论】:

    猜你喜欢
    • 2021-05-01
    • 2019-07-09
    • 2019-06-19
    • 1970-01-01
    • 2021-03-20
    • 2021-10-23
    • 2019-10-29
    • 2020-09-27
    • 2020-04-07
    相关资源
    最近更新 更多