title: Instantiating Geocoder causes NullPointerException
body: <p>Instantiating the <code>Geocoder</code> causes my app to crash with <code>NullPointerException</code>.</p>
  
  <p>This is my code (only single Activity):</p>
  
  <pre><code>public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  
      private final int MAX_RESULTS = 1;
  
      //if I comment out the following line, app will not crash
      private Geocoder geocoder = new Geocoder(getApplicationContext()); //line 27
  
      private GoogleMap gmap;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_maps);
          SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
      }
  
      @Override
      public void onMapReady(GoogleMap map) {
          setUpMap(map);
          gmap = map;
      }
  
      ...
  }
  </code></pre>
  
  <p>I have tried <code>new Geocoder(getBaseContext())</code>, <code>new Geocoder(this)</code> and <code>new Geocoder(MapsActivity.this)</code> but they all crash. How to fix this?</p>
  
  <p>logcat:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
              at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
              at android.location.GeocoderParams.&lt;init&gt;(GeocoderParams.java:50)
              at android.location.Geocoder.&lt;init&gt;(Geocoder.java:83)
              at android.location.Geocoder.&lt;init&gt;(Geocoder.java:95)
              at rubiks.cres.MapsActivity.&lt;init&gt;(MapsActivity.java:27)
  </code></pre>