1

In my project I am using this library, a DatePickerDialog, together with HoloEverywhere and a few other minor view libraries. My problem is, that I am getting a NullPointerException when I try to create this dialog only on 2.3.3 devices.

The weird thing, however, is that when I use this library and create the dialog with the exact same code in other projects (eg HoloEverywhere demo) it works perfectly on all devices. I'm creating the DatePickerDialog with the following code from within a (HoloEverywhere) Activity's onClick method:

final DatePickerDialog dpd = DatePickerDialog.newInstance(this, 2013, 5, 16, false);
        dpd.setYearRange(2013, 2015);
        dpd.show(getSupportFragmentManager(), "datepicker");

Which gives me the following error:

08-19 20:55:45.434: E/AndroidRuntime(1330): FATAL EXCEPTION: main
08-19 20:55:45.434: E/AndroidRuntime(1330): java.lang.NullPointerException
08-19 20:55:45.434: E/AndroidRuntime(1330):     at com.fourmob.datetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:203)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.os.Handler.handleCallback(Handler.java:587)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.os.Looper.loop(Looper.java:130)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at java.lang.reflect.Method.invoke(Method.java:507)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-19 20:55:45.434: E/AndroidRuntime(1330):     at dalvik.system.NativeStart.main(Native Method)

The class/line mentioned in the stacktrace can be found here

Hope this is enough info. Cheers guys.

  • It seems to me that there's a layout used for this - do you have it - does have an id? – g00dy Aug 19 '13 at 09:23
  • All layout stuff is done in the library. [See here](https://github.com/flavienlaurent/datetimepicker/blob/master/datetimepicker-library/res/layout) for the layout and its ids. The mentioned layout file is date_picker_dialog.xml, but it uses s so I linked the whole folder. – JohnathanSmithy Aug 19 '13 at 09:27
  • Well, on line 203 (from the LogCat) I see this `this.mMonthAndDayView.setOnClickListener(this);`, which is `this.mMonthAndDayView = ((LinearLayout) view.findViewById(R.id.date_picker_month_and_day));`. The link you gave me does not contain this layout. – g00dy Aug 19 '13 at 11:59

1 Answers1

1

Turns out another library I had also implemented (android-betterpickers) also contained a /res/date_picker_dialog.xml. Somehow this led to confusion on Gingerbread only (weird but true). It was resolved by renaming the date_picker_dialog.xml file.

  • OMG i was looking for this soooo long, i tried a lot of things :S thanks a lot renaming works :D – Javier Feb 24 '14 at 07:31