flutter - 如何停止 flutter 应用程序中的firebase错误

标签 flutter firebase-authentication flutter-dependencies

我的应用程序没有再次构建,不知道我做错了什么。下面列出了错误消息

C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:9: error: package androidx.annotation does not exist
import androidx.annotation.NonNull;
                          ^
C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:10: error: package androidx.annotation does not exist
import androidx.annotation.Nullable;
                          ^
C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:638: error: cannot find symbol

最佳答案

解决方案

firebase_auth 库build.gradle 中添加:implementation 'androidx.annotation:annotation:1.0.1'。我使用 Android Studio 来查看 Flutter 的 android 应用结构。


来自 Android Studio

enter image description here

示例代码:

build.graddle(firebase_auth 库):
android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 16
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    dependencies {
        api 'com.google.firebase:firebase-auth:16.0.1'
        implementation 'androidx.annotation:annotation:1.0.1'
    }
}
pubspec.yaml(依赖项)
  flutter:
    sdk: flutter
  rxdart: ^0.20.0
  firebase_core: ^0.3.0
  firebase_analytics: ^2.0.0
  firebase_auth: ^0.8.0+1
  google_sign_in: ^4.0.0

关于flutter - 如何停止 flutter 应用程序中的firebase错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54375396/

相关文章:

firebase - 有没有办法使用 Firebase 检查凭据?

flutter - 我可以避免这个错误吗? E/InputMethodManager : Failed to get fallback IMM with expected . flutter.plugins.webviewflutter.InputAwareWebView

flutter - 插件规范无效。 "macos"插件规范无效。在生成应用程序包时

flutter - dart - 如何解决 'The argument type ' Null' can't be assigned to the parameter type 'MyUser' .'

flutter - 如何在浏览器中为 Flutter Web App 配置返回按钮

firebase - flutter firebase google登录以及如何从多个类访问

android - 任务 ':app:preDebugBuild' 的 Flutter 执行失败

iOS Firebase 身份验证与不同的项目

flutter - CocoaPods 在 ios 目录中找不到 pod "FBSDKLoginKit"的兼容版本

reactjs - 为什么我需要在 firebase 中取消订阅 `onAuthStateChanged`