gpt4 book ai didi

android - 必须在 AndroidManifest.xml 中设置有效的 Facebook 应用程序 ID

转载 作者:太空狗 更新时间:2023-10-29 16:27:22 28 4
gpt4 key购买 nike

我正在尝试使用 native react 和 fbsdk 包装器在 Android 上设置 fbsdk https://github.com/facebook/react-native-fbsdk .我让它在 iOS 上工作,但我被困在 Android 上。我按照 github 自述文件执行了所有步骤。

主应用程序.java

@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
SoLoader.init(this, /* native exopackage */ false);
}

字符串.xml

<resources>
<string name="app_name">FacebookLogin</string>
<string name="facebook_app_id">1343643482425305</string>
<string name="fb_login_protocol_scheme">fb1343643482425305</string>
</resources>

AndroidManifest.xml

<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>

但是我从 LogCat 收到这个错误

11-22 06:57:13.236 7570-7570/? I/zygote: Not late-enabling -Xcheck:jni (already on)
11-22 06:57:13.244 7570-7570/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
11-22 06:57:13.361 7570-7570/com.facebooklogin 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:276)
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232)
at com.facebook.internal.FacebookInitProvider.onCreate(FacebookInitProvider.java:20)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1919)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
11-22 06:57:13.364 7570-7570/com.facebooklogin D/AndroidRuntime: Shutting down VM
11-22 06:57:13.365 7570-7570/com.facebooklogin E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.facebooklogin, PID: 7570
java.lang.RuntimeException: Unable to create application com.facebooklogin.MainApplication: 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.handleBindApplication(ActivityThread.java:5794)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
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:276)
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232)
at com.facebooklogin.MainApplication.onCreate(MainApplication.java:53)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5791)
at android.app.ActivityThread.-wrap1(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6541) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

最佳答案

在我的案例中,元数据位于应用程序范围之外。通常,它应该像这样位于您的 list 中:

<application>
...
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
</application>

关于android - 必须在 AndroidManifest.xml 中设置有效的 Facebook 应用程序 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47428898/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com