Could not initialize LoginButton Facebook-sdk for android

流过昼夜 提交于 2019-12-01 04:03:16

This is due to non-initialization of FacebookSdk before its usage. Just add below line:

FacebookSdk.sdkInitialize(mContext);

in case host of LoginButton is:
1.Activity- before setContentView(R.layout.activity_main)
2.Fragment- before inflater.inflate(R.layout.fragment_main, container, false)

Also don't forget to listen the callback in onActivityResult() in above cases to update the UI of LoginButton.

Ramesh_D

I checked on latest SDK4.0.1, in that com.facebook.login.widget.LoginButton is available. But this was not found in facebook-android-sdk-3.17.1, there we have only com.facebook.widget.LoginButton available. Facebook didn't notified the developers or in their changelogs that LoginButton class moved to sub folder.

Very strange why facebook not updating correctly.. Even the doc for Android login is wrong!!

Add this to you Manifest.xml

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
<meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!