简体   繁体   中英

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

The fasebook SDK is linked to my app, this I know from successfully importing LoginButton in the activity class.

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?

As mentioned in the update, there is a conflict with the facbook and google services. I have removed the android-support-v4.jar from the libs folder in my project, then I cleared the project. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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