简体   繁体   English

Android上的Facebook登录按钮和Google服务错误

[英]Facebook login button and google services error on Android

I have made all the prerequirments for integrating facebook SDK with my app, like described here . 我已做了所有的prerequirments整合Facebook的SDK与我的应用程序,如描述在这里 I have followed the documentation, but I am getting an error when I am adding the com.facebook.widget.LoginButton (the login button) to my layout. 我已经按照文档进行操作,但是将com.facebook.widget.LoginButton (登录按钮)添加到布局中时出现错误。

The fasebook SDK is linked to my app, this I know from successfully importing LoginButton in the activity class. fasebook SDK已链接到我的应用程序,通过成功将LoginButton导入LoginButton知道这一点。

More details about the error. 有关该错误的更多详细信息。 Here is the code of the layout: 这是布局的代码:

<?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>

I can't see the result in the Graphical Layout tab. 我在“图形布局”选项卡中看不到结果。 There are no errors under the problem view, and when I run the app I get this log: 问题视图下没有错误,当我运行该应用程序时,我收到以下日志:

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

Did I miss something? 我错过了什么?

Update: I am using also google services, when removing it the view in the Graphical Layout is seems to be ok, but there are many other errors because I removed the google services from my build path. 更新:我也使用谷歌服务,当删除它的图形布局中的视图似乎还可以,但是还有很多其他错误,因为我从构建路径中删除了谷歌服务。

How can I make facebook SDK and google services live nice together? 我怎样才能使Facebook SDK和Google Services相处融洽?

As mentioned in the update, there is a conflict with the facbook and google services. 如更新中所述,facbook和Google服务存在冲突。 I have removed the android-support-v4.jar from the libs folder in my project, then I cleared the project. 我从项目的libs文件夹中删除了android-support-v4.jar ,然后清除了该项目。 This solved my problem.You may also will need to remove google services library (project right click -> Android, under library) and then add it again. 这解决了我的问题。您可能还需要删除Google服务库(在库下,右键单击项目-> Android,然后再次添加它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM