我已经制定了将facebook SDK与我的应用集成的所有优惠,如here所述。
我已经按照文档进行了操作,但是当我将com.facebook.widget.LoginButton
(登录按钮)添加到我的布局时出现错误。
fasebook SDK已链接到我的应用,我知道这是在活动类中成功导入LoginButton
。
有关错误的更多详细信息。 这是布局的代码:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<EditText
android:id="@+id/LoginActivity_email_EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="80dp"
android:ems="10"
android:hint="@string/email"
android:inputType="textEmailAddress" >
<requestFocus android:layout_width="match_parent" />
</EditText>
<EditText
android:id="@+id/LoginActivity_password_EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/LoginActivity_email_EditText"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<Button
android:id="@+id/LoginActivity_forgot_login_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/login" />
<Button
android:id="@+id/LoginActivity_sign_up_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/sign_up" />
</LinearLayout>
<Button
android:id="@+id/LoginActivity_forgot_password_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/LoginActivity_password_EditText"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp"
android:background="#FFFFFF"
android:text="@string/forgot_password" />
<com.facebook.widget.LoginButton
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/LoginActivity_forgot_password_Button"
android:layout_centerHorizontal="true" />
</RelativeLayout>
我无法在“图形布局”选项卡中看到结果。问题视图下没有错误,当我运行应用程序时,我得到了这个日志:
05-05 00:03:57.038: E/AndroidRuntime(3035): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.evapp.activities/com.evapp.activities.LoginActivity}: android.view.InflateException: Binary XML file line #69: Error inflating class com.facebook.widget.LoginButton
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.os.Handler.dispatchMessage(Handler.java:102)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.os.Looper.loop(Looper.java:136)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-05 00:03:57.038: E/AndroidRuntime(3035): at java.lang.reflect.Method.invokeNative(Native Method)
05-05 00:03:57.038: E/AndroidRuntime(3035): at java.lang.reflect.Method.invoke(Method.java:515)
05-05 00:03:57.038: E/AndroidRuntime(3035): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-05 00:03:57.038: E/AndroidRuntime(3035): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-05 00:03:57.038: E/AndroidRuntime(3035): at dalvik.system.NativeStart.main(Native Method)
05-05 00:03:57.038: E/AndroidRuntime(3035): Caused by: android.view.InflateException: Binary XML file line #69: Error inflating class com.facebook.widget.LoginButton
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-05 00:03:57.038: E/AndroidRuntime(3035): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.Activity.setContentView(Activity.java:1929)
05-05 00:03:57.038: E/AndroidRuntime(3035): at com.evapp.activities.LoginActivity.onCreate(LoginActivity.java:29)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.Activity.performCreate(Activity.java:5231)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-05 00:03:57.038: E/AndroidRuntime(3035): ... 11 more
05-05 00:03:57.038: E/AndroidRuntime(3035): Caused by: java.lang.reflect.InvocationTargetException
05-05 00:03:57.038: E/AndroidRuntime(3035): at java.lang.reflect.Constructor.constructNative(Native Method)
05-05 00:03:57.038: E/AndroidRuntime(3035): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
05-05 00:03:57.038: E/AndroidRuntime(3035): ... 22 more
05-05 00:03:57.038: E/AndroidRuntime(3035): Caused by: android.content.res.Resources$NotFoundException: File Enable Google Play services from drawable resource ID #0x7f060006: .xml extension required
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.content.res.Resources.loadColorStateList(Resources.java:2260)
05-05 00:03:57.038: E/AndroidRuntime(3035): at android.content.res.Resources.getColor(Resources.java:817)
05-05 00:03:57.038: E/AndroidRuntime(3035): at com.facebook.widget.LoginButton.<init>(LoginButton.java:237)
05-05 00:03:57.038: E/AndroidRuntime(3035): ... 25 more
我错过了什么吗?
更新 我正在使用谷歌服务,当删除它时,图形布局中的视图似乎没问题,但还有许多其他错误,因为我从我的构建路径中删除了谷歌服务。
如何让facebook SDK和google服务一起生活得很好?
答案 0 :(得分:0)
如更新中所述,与facbook和Google服务存在冲突。我已从项目中的libs文件夹中删除了android-support-v4.jar
,然后我清除了该项目。这解决了我的问题。您可能还需要删除Google服务库(项目右键单击 - &gt; Android,在库下),然后重新添加。