Facebook登录与Flutter集成

时间:2019-02-25 05:42:03

标签: android flutter integration facebook-login flutter-dependencies

我正在尝试按照here为Android提供的说明将Facebook登录与Flutter集成。

我认为这是一个官方插件,我已经遵循了本文档中的所有内容,但是在启动时遇到了以下错误和应用程序崩溃。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shrishtionline.quikpayagent/com.shrishtionline.quikpayagent.MainActivity}: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6251)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1075)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
 Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
    at com.facebook.internal.Validate.sdkInitialized(Validate.java:143)
    at com.facebook.login.LoginManager.<init>(LoginManager.java:79)
    at com.facebook.login.LoginManager.getInstance(LoginManager.java:92)
    at com.roughike.facebooklogin.facebooklogin.FacebookLoginPlugin$FacebookSignInDelegate.<init>(FacebookLoginPlugin.java:109)
    at com.roughike.facebooklogin.facebooklogin.FacebookLoginPlugin.<init>(FacebookLoginPlugin.java:38)
    at com.roughike.facebooklogin.facebooklogin.FacebookLoginPlugin.registerWith(FacebookLoginPlugin.java:42)
    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:23)
    at com.shrishtionline.quikpayagent.MainActivity.onCreate(MainActivity.java:11)
    at android.app.Activity.performCreate(Activity.java:6666)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)

我已经为IOS和Android集成了google登录功能,但是在Facebook登录中却卡住了。

错误日志说要调用FacebookSdk.sdkInitialize(),但是在dart中,我无法调用此代码。但是我已经用static final FacebookLogin facebookSignIn = new FacebookLogin();方法初始化了Facebook SDK。

我浏览了很多,但无法解决此问题。

2 个答案:

答案 0 :(得分:0)

您提到的插件正确。我想您错过了根据错误日志初始化SDK的方法。

我建议您按照下面由Rohan Taneja编写的教程中的步骤进行操作。

教程:https://medium.com/flutter-community/flutter-facebook-login-77fcd187242

答案 1 :(得分:0)

问题已解决。只需运行flutter clean并重新运行项目即可。