[英]MissingPluginException(No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth)
I got this problem at sign in function with firebase, I don't know how to solve it.我在使用 firebase 登录功能时遇到了这个问题,我不知道如何解决。 Please help, thanks.
请帮忙,谢谢。
the code of my sign in function is like:我的登录功能代码如下:
Future<void> signIn() async{
final formState = _formKey.currentState;
if(formState.validate()){
//TODO login to firebase
formState.save();
try{
FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(email: _email, password: _password);
Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(user: user)));
}catch(e){
print(e.details);
}
}
} }
and my flutter doctor is like:我的颤振医生就像:
[✓] Flutter (Channel master, v1.4.20-pre.2, on Mac OS X 10.14.4 18E226, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[!] Android Studio (version 3.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.8)
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)
the output of the error is like:错误的输出是这样的:
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception:
MissingPluginException(No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth)
0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
<asynchronous suspension>
1 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:278:54)
<asynchronous suspension>
2 FirebaseAuth.signInWithEmailAndPassword (package:firebase_auth/src/firebase_auth.dart:249:12)
3 _LoginPageState.signIn (package:pdc/Pages/Setup/signIn.dart:62:57)
<asynchronous suspension>
4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
8 TapGestureR<…>
It happens both on my device and IOS simulator, and I didn't try it on android.它发生在我的设备和 IOS 模拟器上,我没有在 android 上尝试过。 I have already tried the flutter clean, start a new project, and upgrade the cocoaPods.
我已经尝试过flutter clean,开始一个新项目,并升级cocoaPods。 But none of them is useful to my case.
但它们都对我的情况没有用。 Thanks for help.
感谢帮助。
It seems that whenever I try to do something with firebase, it will come up to this kind of question.似乎每当我尝试使用 firebase 做某事时,都会遇到此类问题。 I wrote code to sign up like this:
我写了这样的注册代码:
Future<void> signUp() async{
if(_formKey.currentState.validate()){
_formKey.currentState.save();
FirebaseUser user = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password);
Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(user: user)));
}
}
The output of my code is我的代码的输出是
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method createUserWithEmailAndPassword on channel plugins.flutter.io/firebase_auth)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
<asynchronous suspension>
#1 FirebaseAuth.createUserWithEmailAndPassword (package:firebase_auth/src/firebase_auth.dart:108:54)
<asynchronous suspension>
#2 _LoginPageState.signUp (package:pdc/Pages/Setup/signIn.dart:78:55)
<asynchronous suspension>
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
#7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
#8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436:9)
And I'm sure I finished the setup of firebase and successfully connected flutter app with firebase.而且我确定我完成了 firebase 的设置并成功地将 flutter 应用程序与 firebase 连接。
I had a really hard time in making Firebase work.我真的很难让 Firebase 工作。 I think it should be REALLY easy, as both Flutter and Firebase are Google products.
我认为这应该非常简单,因为 Flutter 和 Firebase 都是 Google 的产品。 Anyway, I had to use this code for the
AppDelegate.m
file in iOS:无论如何,我不得不在 iOS 中的
AppDelegate.m
文件中使用此代码:
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@import UIKit;
@import Firebase;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions]; // YES;
}
@end
Have you tried something like this already?你有没有尝试过这样的事情?
我遇到了同样的问题并通过升级 firebase_auth 包来解决它。
I believe you need to run packages get & upgrade.我相信您需要运行包获取和升级。 If you are using Android studio you can just go in your pubspeck.yaml file and two buttons will appear in the top right corner or you can just use your terminal.
如果您使用的是 Android Studio,您可以直接进入 pubspeck.yaml 文件,右上角会出现两个按钮,或者您可以直接使用终端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.