I am integrating the Faecbook SDK into an existing react-native project and having the dreaded error: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
I have followed the instructions carefully, so strings.xml contains:
<string name="facebook_app_id">xxxxx</string>
And in AndroidManifest.xml, inside the application element, I have
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
I've made the changes to settings.gradle and build.xml as described.
All the instructions say that I shouldn't need to call FacebookSdk.sdkInitialize()
if I have done the above. I'm using react-native-fbsdk version 1.1.1 and react native 0.60.5
When I followed the instructions on a simple new react-native project it works, so I am wondering if it is a conflict with something in the app, but I'm not sure what to look for. Can anyone suggest how to debug?
Thanks.
In case it helps anyone else, I found the culprit by creating a vanilla react-native app with fbsdk integration and painstakingly copying in config from my real app until the facebook integration stopped working.
It turns out that removing tools:node="replace"
from the application element in AndroidManifest.xml fixed the problem.
<application
...
tools:node="replace">
(I'm not sure why this attribute had been added, the git commit message from the developer who added it was enigmatic and the app still seems to work without it...)