我的应用程序“不幸停止"在安装和配置react-native-fbsdk
软件包后,在Android模拟器中启动。
我已按照文档中的指导安装了此软件包。
在adb logcat
我得到了这个日志。
09-18 17:02:05.251 1545 1557 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.exampleproject/.MainActivity (has extras)} from uid 10008 on display 0
09-18 17:02:05.489 1545 2041 I ActivityManager: Start proc 29665:com.exampleproject/u0a67 for activity com.exampleproject/.MainActivity
09-18 17:02:05.518 29665 29665 E AndroidRuntime: Process: com.exampleproject, PID: 29665
09-18 17:02:05.518 29665 29665 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.exampleproject.MainApplication: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
09-18 17:02:05.518 29665 29665 E AndroidRuntime: at com.exampleproject.MainApplication.onCreate(MainApplication.java:56)
09-18 17:02:05.732 1545 3286 W ActivityManager: Force finishing activity com.exampleproject/.MainActivity
09-18 17:02:06.315 1545 1559 W ActivityManager: Activity pause timeout for ActivityRecord{47cc657 u0 com.exampleproject/.MainActivity t51 f}
09-18 17:02:17.062 1545 1559 W ActivityManager: Activity destroy timeout for ActivityRecord{47cc657 u0 com.exampleproject/.MainActivity t51 f}
据我所知,这个日志是A valid Facebook app id must be set in the AndroidManifest.xml
。我已正确设置Facebook应用程序。
我在strings.xml
<string name="facebook_app_id">realFBappID</string>
并在应用程序元素
中添加了元数据元素<application android:label="@string/app_name" ...>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
...
</application>
每件事对我来说都是正确的。即使应用程序无法正常工作。请指导这里的问题....
答案 0 :(得分:0)
在Facebook上创建应用并添加它的ID enter link description here
在strings.xml
<resources>
<string name="facebook_app_id">someid...</string> // you need to add real Facebook app id and wrap it in resources
</resources>
在android中
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"
/>