[英]Android, Facebook Login Button Causes Crash (SDK 4.0.0)
在我的活动.xml
文件中,我包含了Facebook登录按钮(来自此文档)
<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
文档说到
使用完整的类名com.facebook.widget.LoginButton将按钮添加到布局XML文件中
但改变顶线没有任何作用。 应用程序立即崩溃,无需打开,日志cat中没有记录任何内容(在外部设备上进行测试)。
删除按钮或将其更改为
<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,不知道常规按钮是否有效。
先感谢您。
添加FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
在给视图充气之前..
- 如果在活动中使用此xml,请在setContentView()
之前写入上面的行
- 如果在片段中使用此xml,请在inflater.inflate...
之前写入此行inflater.inflate...
并且,只需忽略布局预览窗口中显示的警告
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.