在我的应用程序中,我添加了以下依赖项,以便在我的代码中开始使用facebook API。
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.facebook.android:account-kit-sdk:4.+'
但是我在应用程序代码中添加了这些依赖项而没有其他东西。我的应用程序在启动时开始崩溃。
java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: 500:
Initialization error: 503:
The Client Token must be specified in the string resource file as com.facebook.accountkit.ClientToken
at android.app.ActivityThread.installProvider(ActivityThread.java:4911)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4503)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4443)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
Caused by: 500: Initialization error: 503: The Client Token must be specified in the string resource file as com.facebook.accountkit.ClientToken
at com.facebook.accountkit.internal.Initializer.getRequiredString(Initializer.java:225)
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:115)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:540)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1616)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1587)
at android.app.ActivityThread.installProvider(ActivityThread.java:4908)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4503)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4443)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
编辑: 我还添加了Menifest后来
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider******"
android:exported="true" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/fbAppId" />
在我的Application类
中 @Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}
}
但仍然崩溃不知道这个错误来自哪里?但是,当我删除这些依赖项时,我的代码运行正常。
答案 0 :(得分:1)
客户端令牌必须在字符串资源文件中指定为com.facebook.accountkit.ClientToken
它清楚地表明您必须在清单文件中有com.facebook.accountkit.ClientToken
及其令牌
添加
<meta-data
android:name="com.facebook.accountkit.ClientToken"
android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />
在你的Menifest文件中。
有关详细信息,请访问https://developers.facebook.com/docs/accountkit/android