'FacebookSdk not starting android
I have tried everything from tutorials, answers all around, even with examples from https://github.com/facebook/facebook-android-sdk/tree/master/samples. I have tried with test app and normal app in developers.facebook.com/apps
But i always get this error A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
Full error:
05-31 22:19:09.798 2895-2895/jonjon.fb1 I/art: Not late-enabling -Xcheck:jni (already on)
05-31 22:19:09.868 2895-2895/jonjon.fb1 W/System: ClassLoader referenced unknown path: /data/app/jonjon.fb1-1/lib/x86_64
05-31 22:19:09.888 2895-2895/jonjon.fb1 I/FacebookInitProvider: Failed to auto initialize the Facebook SDK
A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:275)
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:231)
at com.facebook.internal.FacebookInitProvider.onCreate(FacebookInitProvider.java:20)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-31 22:19:09.892 2895-2895/jonjon.fb1 D/AndroidRuntime: Shutting down VM
--------- beginning of crash
05-31 22:19:09.892 2895-2895/jonjon.fb1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: jonjon.fb1, PID: 2895
java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: 500: Initialization error: 502: The App Id must be specified in the string resource file as com.facebook.sdk.ApplicationId
at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: 500: Initialization error: 502: The App Id must be specified in the string resource file as com.facebook.sdk.ApplicationId
at com.facebook.accountkit.internal.Initializer.getRequiredString(Initializer.java:228)
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:113)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-31 22:41:18.585 3969-3969/jonjon.fb1 D/AndroidRuntime: Shutting down VM
05-31 22:41:18.585 3969-3969/jonjon.fb1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: jonjon.fb1, PID: 3969
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:5156)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
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:228)
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:118)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Solution 1:[1]
Add
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//initialize Facebook SDK
FacebookSdk.sdkInitialize(getApplicationContext());
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}
setContentView(R.layout.activity_main); }
Solution 2:[2]
It fails to initialize the library. I think the solution as said in the logcat is to add a string in strings.xml with the name
com.facebook.sdk.ApplicationId
As value you must put the token Then you can call
FacebookSdk.sdkInitialize(this);
In onCreate
Solution 3:[3]
Since FacebookSdk.sdkInitialize(getApplicationContext());
is deprecated. You can use these methods to initialize facebookSDK
FacebookSdk.fullyInitialize();
AppEventsLogger.activateApp(application);
It works fine
Solution 4:[4]
Add
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//initialize Facebook SDK
FacebookSdk.setClientToken("XXXXXXXXXXXXX");
FacebookSdk.sdkInitialize(getApplicationContext());
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
} }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ali Obeid |
Solution 2 | dade.sliep |
Solution 3 | Suraj Rao |
Solution 4 | Navneet Tiwari |