title: Illegalstateexception Fragment must be public static class to be properly recreated from instance state
body: <p>below is the code which is throwing the error message  </p>
  
  <blockquote>
    <p>"<strong>java.lang.illegal state exception:Fragment must be public static
    class to be properly recreated from instance state</strong> "</p>
  </blockquote>
  
  <p>The below code snippet throwing error only after i included <code>**compile 'com.google.android.gms:play-services-ads:11.8.0'</code>** in build.gradle file, else working fine.</p>
  
  <pre><code>public void selectDate(View view) {
              DialogFragment newFragment = new SelectDateFragment();
              newFragment.show(getFragmentManager(), "DatePicker");
          }
  
  @SuppressLint("ValidFragment")
  public class SelectDateFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
              @Override
              public Dialog onCreateDialog(Bundle savedInstanceState) {
                  final Calendar calendar = Calendar.getInstance();
                  int yy = calendar.get(Calendar.YEAR);
                  int mm = calendar.get(Calendar.MONTH);
                  int dd = calendar.get(Calendar.DAY_OF_MONTH);
                  return new DatePickerDialog(getActivity(), this, yy, mm, dd);
              }
  </code></pre>