jeduan / cordova-plugin-facebook4

Use the latest Facebook SDK in your Cordova and Ionic projects
Other
767 stars 511 forks source link

Unable to start the app and initializing the SDK. #876

Closed AbdullaevTimur closed 3 years ago

AbdullaevTimur commented 4 years ago

I user the latest version. After the android platform build, I see that there no any facebook and tags in AndroidManifest.xml file. I try to add it by myself and then, when I try to launch My app I get error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app/my.app.MainActivity}: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2604) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2670) at android.app.ActivityThread.access$1100(ActivityThread.java:178) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768) Caused by: 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:292) at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:245) at org.apache.cordova.facebook.ConnectPlugin.pluginInitialize(ConnectPlugin.java:84) at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:58) at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171) at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97) at org.apache.cordova.PluginManager.init(PluginManager.java:86) at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:117) at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149) at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224) at app.placehot.MainActivity.onCreate(MainActivity.java:39) at android.app.Activity.performCreate(Activity.java:6340) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557) ... 9 more

I check all my Facebook credentials and they are correct. I think a lot of people can facing with this issue. What i should do to avoid this error.

AbdullaevTimur commented 4 years ago

I resolve this issue by adding new string in src/android/ConnectPlugin.java:82. I append FacebookSdk.setApplicationId(FACEBOOK_APP_ID); before string FacebookSdk.sdkInitialize(cordova.getActivity().getApplicationContext());

But the quastion is "How use global variables like APP_ID from config.xml in this .java file"?

noahcooper commented 3 years ago

This plugin is deprecated. Check out cordova-plugin-facebook-connect at https://www.npmjs.com/package/cordova-plugin-facebook-connect.

It's hard to tell without more detail what your issue was, but there's no reason you should need to edit the plugin's Java code. The APP_ID is automatically set in the manifest at build time.