I get reports of NullPointerExceptions in onPrepareDialog in line 860 (method call to prepareCongratulationsDialog(dialog)): @Override protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); switch (id) { case DIALOG_CONGRATULATIONS: prepareCongratulationsDialog(dialog); // line 860 break; case DIALOG_...: // some code } }
private void prepareCongratulationsDialog(Dialog dialog) { // some code }; The dialog is a managed dialog opened using showDialog(DIALOG_CONGRATULATIONS) The stack trace looks like this: java.lang.NullPointerException at com.company.app.MyActivity.onPrepareDialog(MyActivity.java:860) at android.app.Activity.onPrepareDialog(Activity.java:2505) at android.app.Activity.showDialog(Activity.java:2555) at android.app.Activity.showDialog(Activity.java:2514) ... I normally can't reproduce the problem (only once so far) and it seems to happen on arbitrary devices and Android versions but once it occurs it seems to have a certain persistency (I normally get several crash reports from the same devices). How could that line possibly cause an NPE? Even if dialog were null (which it isn't, I had a productive version that tested against dialog being null and that didn't help), at least prepareCongratulationsDialog should be called. In that case the stack trace would show the line of code in prepareCongratulationsDialog causing the NPE (tested that as well just to make sure). I tried to put a try catch around the method call. What happened is that the app didn't crash and the dialog appeared but "unprepared" meaning with all the %1$s etc. placeholders that the onPrepareDialog is supposed to replace. If the method prepareCongratulationsDialog itself isn't crashing how could line 860 possibly cause an NPE? Could the fact that I'm using ProGuard be related to these crashes? Any help is very much appreciated. Emanuel Moecklin 1gravity LLC -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en