gpt4 book ai didi

Android、Facebook 登录按钮导致崩溃 (SDK 4.0.0)

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:45:29 25 4
gpt4 key购买 nike

在我的 Activity .xml 文件中,我包含了 Facebook 登录按钮(来自 this 文档)

    <com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />

我立即收到警告

The following classes could not be found:
- com.facebook.login.widget.LoginButton

文档说到

Add the button to your layout XML file with the full class name, com.facebook.widget.LoginButton

但是更改顶行没有任何作用。应用程序立即崩溃,无法打开,并且日志猫中没有任何记录(在外部设备上测试)。

删除按钮,或将其更改为

    <Button
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />

停止崩溃,但这是我第一次使用 Facebook SDK,不知道常规按钮是否有效。

提前谢谢你。

最佳答案

在膨胀 View 之前添加 FacebookSdk.sdkInitialize(getActivity().getApplicationContext());..
- 如果在 Activity 中使用此 xml,请在 setContentView() 之前写上一行
- 如果在 fragment 中使用此 xml,请在 inflater.inflate... 之前写此行

并且,忽略布局预览窗口中显示的警告

关于Android、Facebook 登录按钮导致崩溃 (SDK 4.0.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29314349/

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