我從我的應用程序發送我的錯誤日誌,收到此異常,當它崩潰:支持Android V4 DialogFragment崩潰應用
java.lang.RuntimeException: Unable to start activity ComponentInfo{<my activity>}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3553)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v4.app.DialogFragment.onActivityCreated(DialogFragment.java:368)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1486)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
at <my FragmentActivity wrapper>.onStart(BaseActivity.java:16)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
at android.app.Activity.performStart(Activity.java:5216)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
... 12 more
我一直無法重現它,並記錄導致這一崩潰似乎沒有表明有任何DialogFragment
顯示。 This is the line in the support library that is causing the crash
顯示用於創建和顯示對話框的代碼。 –
NullPointerException似乎會導致您的問題,請張貼您的代碼,尤其是發生異常的部分,以便我們可以幫助您解決問題。 –
'getActivity()'返回'null',這意味着'DialogFragment'沒有附加到'Activity'。將代碼發佈到您正在調用DialogFragment的地方。 –