how to integrate facebook in android using facebook sdk 4.10

后端 未结 1 523
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 02:29

Hi when I am using Login button in my XML, I am getting exception like \"The following classes could not be instantiated: - com.facebook.login.widget.LoginButton (Open Class

相关标签:
1条回答
  • 2020-12-22 02:53

    This is xml code of fb sdk example like this

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:facebook="http://schemas.android.com/apk/res-auto"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:background="#FFF"
            >
        <LinearLayout android:orientation="vertical"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:background="#FFF"
                      android:id="@+id/main_ui_container">
            <com.facebook.login.widget.LoginButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_gravity="center_horizontal"
                facebook:confirm_logout="false"
                facebook:tooltip_mode="never_display"
                />
            <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                >
                <TextView
                        android:id="@+id/greeting"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_gravity="center"
                        android:textColor="#333"
                        android:textSize="18sp"/>
                <com.facebook.login.widget.ProfilePictureView
                        android:id="@+id/profilePicture"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:gravity="center_horizontal"
                        android:layout_marginBottom="10dp"
                        facebook:preset_size="normal"/>
                <Button
                        android:id="@+id/postStatusUpdateButton"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Post Status Update"
                        />
                <Button
                        android:id="@+id/postPhotoButton"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Post Photo"
                        />
    
            </LinearLayout>
        </LinearLayout>
    
    </LinearLayout>
    

    And Mainfeast file like this

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
              package="com.facebook.samples.hellofacebook"
              android:versionCode="1"
              android:versionName="1.0">
        <uses-sdk android:minSdkVersion="9"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <application android:label="@string/app_name"
                     android:icon="@drawable/icon"
                     android:theme="@android:style/Theme.NoTitleBar"
                >
            <activity android:name=".HelloFacebookSampleActivity"
                      android:label="@string/app_name"
                      android:windowSoftInputMode="adjustResize">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
            <activity android:name="com.facebook.FacebookActivity"
                      android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                      android:theme="@android:style/Theme.Translucent.NoTitleBar"
                      android:label="@string/app_name" />
            <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
            <meta-data android:name="com.facebook.sdk.ApplicationName"
                       android:value="@string/facebook_app_name" />
            <provider android:authorities="com.facebook.app.FacebookContentProvider355198514515820"
                      android:name="com.facebook.FacebookContentProvider"
                      android:exported="true"/>
            <receiver android:name="com.facebook.samples.hellofacebook.HelloFacebookBroadcastReceiver">
                <intent-filter>
                    <action android:name="com.facebook.platform.AppCallResultBroadcast" />
                </intent-filter>
            </receiver>
        </application>
    </manifest>
    
    0 讨论(0)
提交回复
热议问题