2016-04-09 45 views
1

時,登錄按鈕崩潰問題:
fb button is crashing當您點擊

崩潰報告:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.Fragment com.facebook.internal.FragmentWrapper.getSupportFragment()' on a null object reference 

我有我的機器人工作室升級到2.0,我開始有與應用程序的編譯問題。

  1. 我已經改變 renderscriptTargetApi 23renderscriptTargetApi 20

  2. 從編譯'com.facebook.android:facebook-android-sdk:4.9.0' FB編譯爲compile 'com.facebook.android:facebook-android-sdk:4.8.0'

    錯誤信息:Error:(3, 5) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').

代碼:

相同的代碼是工作到現在。它有android:theme="@android:style/Theme.Holo.Light.NoActionBar" in the activity in manifest file and build.gradle

compileSdkVersion 22 
    buildToolsVersion "22.0.1" 

但它崩潰,現在顯示錯誤:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.Fragment com.facebook.internal.FragmentWrapper.getSupportFragment()' on a null object reference 

我怎樣才能解決呢?

main.xml中

 <com.facebook.login.widget.LoginButton 
      xmlns:facebook="http://schemas.android.com/apk/res-auto" 

      facebook:com_facebook_login_text="login" 

android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="1dp" 
      android:paddingBottom="1dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginLeft="10dp" 
      android:id="@+id/button1" 
      android:textSize="12sp" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true"/> 
+0

你在xml中定義了FacebookActivity嗎? –

+0

這是不可讀的評論發佈在您的問題 –

+0

@VivekMishra我已經添加了我用於xml按鈕的代碼。 – jason

回答

2

我面臨同樣的問題,然後我改變我的Facebook SDK從4.8.0的版本4.13.1

然後,我添加此

compile('com.android.support:cardview-v7:23.2.0') { 
    force = true 
} 

解決cardView錯誤。