在使用最新的SDK版本4.30时尝试通过Facebook登录时出现以下错误:
The SDK has not been initialized,make sure to call
FacebookSdk.sdkInitialize()
然后应用程序崩溃.
虽然,在官方文档中,它应该已经自动初始化.
请注意,FacebookSdk.sdkInitialize()现在已弃用,因此不应调用它!
不调用FacebookSdk.sdkInitialize()时的错误日志:
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.
当强制在应用程序上调用已弃用的FacebookSdk.sdkInitialize()时,会发生以下错误:
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/facebook/common/R$layout; at
com.facebook.FacebookActivity.onCreate(FacebookActivity.java:77)
at android.app.Activity.performCreate(Activity.java:6684) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
P.S:
尝试使用Facebook登录按钮时出错
Error inflating class com.facebook.login.widget.LoginButton
最佳答案
提醒一下,如果有人这样定义的话
原文链接:https://www.f2er.com/android/430192.html<Meta-data android:name="com.facebook.sdk.ApplicationId" android:value="1234"/>
不是https://developers.facebook.com/docs/android/getting-started中的要求
<Meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
他们会得到的
The SDK has not been initialized,make sure to call
FacebookSdk.sdkInitialize()
我在Facebook Share SDK 4.31.0中遇到了这种情况
compile 'com.facebook.android:facebook-share:4.31.0'