gpt4 book ai didi

firebase - MissingPluginException(在 channel plugins.flutter.io/firebase_auth 上找不到方法 signInAnonymously 的实现)

转载 作者:行者123 更新时间:2023-12-03 20:25:45 26 4
gpt4 key购买 nike

我正在尝试在我的 firebase 上匿名登录,我已经添加了 FireBase 页面中显示的所有需要​​的东西,但是由于某种原因,当我尝试匿名登录时,我得到了这个错误:

I/flutter ( 1656): MissingPluginException(No implementation found for method signInAnonymously on 
channel plugins.flutter.io/firebase_auth)
I/flutter ( 1656): Log in error

这是我的匿名登录代码,在我的页面上没有显示任何错误:
import 'package:firebase_auth/firebase_auth.dart';

//Definir os metodos que vao interagir com firebase
class AuthService {

final FirebaseAuth _auth = FirebaseAuth.instance;

//Logar anonimamente
Future signInAnon() async {
try {
AuthResult result = await _auth.signInAnonymously();
FirebaseUser user = result.user;
return user;
}catch (e) {
print(e.toString());
return null;
}
}

在主页面调用它:
import 'package:flutter/material.dart';
import 'package:homeautomation/services/auth.dart';

class _SignInState extends State<SignIn> {
final AuthService _auth = AuthService();
...
Body:
Child: RaisedButton(
child: Text('Logar Anonimamente'),
onPressed: () async {

dynamic result = await _auth.signInAnon();
if (result == null)
{
print('erro ao logar');
}
else
{
print('Logado');
print(result);
}
},
),

重新启动 Android Studio,我现在收到一个不同的错误:
PlatformException(ERROR_API_NOT_AVAILABLE, API: 
InternalFirebaseAuth.FIREBASE_AUTH_API is not available on this device.
Connection failed with: ConnectionResult{statusCode=SERVICE_INVALID,
resolution=null, message=null}, null)
I/flutter ( 2963): erro ao logar

最佳答案

您是否启用了匿名登录 Firebase console ?
,您必须在 Firebase Console 中启用它.

, 运行 flutter clean并且您的代码应该没有错误。

flutter clean不起作用,

Check if the device you are running on has Google Play Services, if it does not. You have to install. it to stop seeing that error.



我希望这有帮助。

关于firebase - MissingPluginException(在 channel plugins.flutter.io/firebase_auth 上找不到方法 signInAnonymously 的实现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61580912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com