2017-05-31 66 views
0


其實我試圖做用戶登錄與Facebook在我的火力點身份驗證的Android應用程序...
如果在此階段創建方法調用
通過異常 setContentView(R.layout.activity_login)代碼此按鈕

的Facebook SDK初始化

<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"/> 

在新的Facebook SDK中的FacebookSdk.sdkInitialize(getApplicationContext())已被棄用,所以我不需要再初始化facebbok SDK,但是當我在那一刻,運行應用程序時我收到以下錯誤..

android.view.InflateException: Binary XML file line #70: Binary XML file line #70: Error inflating class com.facebook.login.widget.LoginButton 

Caused by: android.view.InflateException: Binary XML file line #70: Binary XML file line #70: Error inflating class com.facebook.login.widget.LoginButton 

造成的:該SDK尚未初始化,請務必()首先調用FacebookSdk.sdkInitialize。

,我使用以下依賴

compile 'com.google.firebase:firebase-auth:10.2.6' 
compile 'com.google.firebase:firebase-core:10.2.6' 
compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
+0

'''爲什麼>'這裏卸下襬臂'>' –

回答

0

改變它的佈局文件

<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"/> 
0

由於錯誤提示設置之前調用這行代碼FacebookSdk.sdkInitialize的()內容視圖。您可以在您的應用程序類中執行此操作。說

class YourApplication extends Application{ 
    onCreate(){ 
FacebookSdk.sdkInitialize() 
} 
} 

確保在Android清單應用程序的標籤

<application 
name="YourApplication"> 
0

sdkInitialize方法是在4.19.0版本棄用提供您的應用程序的名稱。我建議你使用最新版本,後者是SDK的

compile 'com.facebook.android:facebook-android-sdk:4.22.1' 
相關問題