【问题标题】:The plugin `firebase_auth` doesn't have a main class defined in C:\Users\插件 `firebase_auth` 没有在 C:\Users\ 中定义的主类
【发布时间】:2021-12-06 14:49:18
【问题描述】:

将 firebase_auth 添加到依赖项 (pubspec.yaml) 到我的颤振项目时,我收到此错误:

插件firebase_auth 没有在 C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android\src 中定义主类\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java 或 C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android \src\main\kotlin\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.kt。这可能是由于插件的 pubspec.yaml 中的 androidPackage: io.flutter.plugins.firebase.authmainClass 条目不正确造成的。 如果您是此插件的作者,请修复 androidPackage 条目或将主类移动到上面使用的任何位置。否则,请联系本插件作者,同时考虑使用其他插件。

我的代码只是 android studio 创建的虚拟代码,我唯一添加的是 firebase_auth: ^3.1.3 in pubsbec.yaml , android/app 目录中的 .json 文件并在 Firebase 网站上注册了该应用程序。

我在 VS Code 中遇到了同样的问题,所以 Android Studio 不是问题。

非常感谢任何帮助!

【问题讨论】:

  • 您是否添加了 firebase_core pugin,因为它是必不可少的,如果您根据文档做了所有事情,那么 flutter clean 之后 pub cache repair 将完成这项工作。然后再次运行
  • 成功了!谢谢!
  • @你的欢迎。请将我的答案标记为解决方案,以便其他人受益。

标签: java android firebase flutter dart


【解决方案1】:

我认为您尚未在 pubspec.yaml 文件中添加 Firebase 核心。尝试在您的 pubspec.yaml 中添加firebase_core 1.7.0,然后使用此命令清理您的项目flutter clean

也可以查看installation guide

【讨论】:

    【解决方案2】:

    添加 firebase_core pugin,因为它是必不可少的,如果您按照文档进行了所有操作,那么在 pub 缓存修复之后,flutter clean 将完成这项工作。然后再次运行。

    【讨论】:

      猜你喜欢
      • 2021-03-19
      • 2020-12-18
      • 2018-01-31
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多