title: How can I extend SupportMapFragment in Android Studio?
body: <p>I want to create a custom map fragment that has my zoom settings, marker, and map type settings so that I can reuse it across several activities. The class I created is called "LiteMap".</p>
  
  <p>I get an error from the compiler 
  <code>'Incompatible Types' 'Required: com.mypackage.LiteMap' 'Found      com.google.android.gms.maps.SupportMapFragment'</code>
  where I call <code>.newInstance</code>. I assume that <code>.newInstance</code> returns the parent class instead of my class but I'm not sure how to override in my class to return my "LiteMap" object. </p>
  
  <p>As an alternative I have tried instantiating my map object using new and I get the following error without any specific line as the source but it appears that using new isn't creating the LiteMap object. Is what I want to do impossible or stupid way of doing it?</p>
  
  <pre><code>03-29 20:36:52.771 11326-11326/com.tremulant.phield E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.tremulant.phield, PID: 11326
    java.lang.RuntimeException: Unable to resume activity {com.tremulant.phield/com.tremulant.phield.ReviewDetails}: java.lang.NullPointerException: Attempt to invoke interface method 'void maps.ei.bz.o()' on a null object reference
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2974)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2371)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5290)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void maps.ei.bz.o()' on a null object reference
        at maps.ei.n.b(Unknown Source)
        at com.google.android.gms.maps.internal.i$a.onTransact(:com.google.android.gms.alldynamite:115)
        at android.os.Binder.transact(Binder.java:380)
        at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onResume(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment$zza.onResume(Unknown Source)
        at com.google.android.gms.dynamic.zza$7.zzb(Unknown Source)
        at com.google.android.gms.dynamic.zza.zza(Unknown Source)
        at com.google.android.gms.dynamic.zza.onResume(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment.onResume(Unknown Source)
        at android.support.v4.app.Fragment.performResume(Fragment.java:2020)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1107)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
        at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:2056)
        at android.support.v4.app.FragmentController.dispatchResume(FragmentController.java:196)
        at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:505)
        at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:494)
        at android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:174)
        at android.app.Activity.performResume(Activity.java:6119)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2963)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2371) 
        at android.app.ActivityThread.access$800(ActivityThread.java:149) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5290) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) 
  03-29 20:36:52.822 11326-11326/? I/Process: Sending signal. PID: 11326 SIG: 9
  </code></pre>
  
  <p>LiteMap Fragment    </p>
  
  <pre><code>package com.tremulant.phield;
  
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.OnMapReadyCallback;
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  public class LiteMap extends SupportMapFragment implements OnMapReadyCallback {
      private GoogleMap mMap;
  
      String lat;
      String lng;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          //super.onCreate(savedInstanceState);
          lat = getArguments().getString("Lat");
          lng = getArguments().getString("Lng");
          return inflater.inflate(R.layout.maplite,null);
  
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap) {
          mMap = googleMap;
  
          LatLng mapVenue = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng));
          mMap.addMarker(new MarkerOptions().position(mapVenue));
          mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mapVenue, 14.0f));
      }
  }
  </code></pre>
  
  <p>maplite.xml layout file for fragment</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="25dp"
            android:layout_height="fill_parent"
            android:weightSum="10"&gt;
  
  
  &lt;fragment
      android:id="@+id/lmap"
      android:layout_width="match_parent"
      android:layout_height="25dp"
      class="com.tremulant.phield.LiteMap" /&gt;
  
   &lt;/LinearLayout&gt;
  
  
  
      package com.tremulant.phield;
  
  import android.content.Intent;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class ReviewDetails extends BaseActivity implements View.OnClickListener{
  
  private Venue mVenue;
  @Override
  public void onClick(View v) {
      Intent mapIntent = new Intent(ReviewDetails.this, VenueMap.class);
      mapIntent.putExtra(VENUE_TRANSFER,mVenue);
      startActivity(mapIntent);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_review_details);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
      Intent intent = getIntent();
      mVenue = (Venue) intent.getSerializableExtra(VENUE_TRANSFER);
  
      LiteMap liteMap = new LiteMap();
      //lmap.setArguments(args);
      android.support.v4.app.FragmentTransaction fragmentTransaction =
              getSupportFragmentManager().beginTransaction();
      fragmentTransaction.add(R.id.map_container, liteMap);
      fragmentTransaction.commit();
      }
  }
  </code></pre>
  
  <p>content_review_details.xml layout file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.tremulant.phield.ReviewDetails"
  tools:showIn="@layout/activity_review_details"&gt;
  
  &lt;FrameLayout
      android:id="@+id/map_container"
      android:layout_below="@id/map"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;/FrameLayout&gt;
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I simplified my code. Also I don't understand why when I paste my code in here it doesn't indent properly. ugh! Now my logcat shows the following in a loop. The screen just stays black when ReviewDetails activity tries to load.</p>
  
  <pre><code>03-30 20:58:28.364 17076-17076/com.tremulant.phield I/ViewRootImpl: 
  
  ViewRoot's Touch Event : ACTION_DOWN
  03-30 20:58:28.466 17076-17076/com.tremulant.phield I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
  03-30 20:58:28.503 17076-17076/com.tremulant.phield I/Timeline: Timeline: Activity_launch_request id:com.tremulant.phield time:25955914
  03-30 20:58:28.552 17076-17076/com.tremulant.phield I/Timeline: Timeline: Activity_launch_request id:com.tremulant.phield time:25955964
  03-30 20:58:28.600 17076-17076/com.tremulant.phield D/ContextHelper: convertTheme. context-&gt;name=com.tremulant.phield themeResourceId=2131427455
  03-30 20:58:28.604 17076-17076/com.tremulant.phield D/ContextHelper: convertTheme. context-&gt;name=com.tremulant.phield themeResourceId=2131427455
  03-30 20:58:28.606 17076-17076/com.tremulant.phield I/PhoneWindow: [generateLayout] setColorNavigationBar =&gt; color=0x ff00796b
  03-30 20:58:28.753 17076-17076/com.tremulant.phield I/zzad: Making Creator dynamically
  03-30 20:58:28.763 17076-17076/com.tremulant.phield W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
  03-30 20:58:28.763 17076-17076/com.tremulant.phield W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
  03-30 20:58:28.839 17076-17076/com.tremulant.phield D/ChimeraCfgMgr: Reading stored module config
  03-30 20:58:28.878 17076-17076/com.tremulant.phield D/ChimeraFileApk: Primary ABI of requesting process is armeabi-v7a
  03-30 20:58:28.879 17076-17076/com.tremulant.phield I/art: DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/arm/data@data@com.google.android.gms@app_chimera@m@00000000@DynamiteModules-prod.apk@classes.dex' for file location '/data/data/com.google.android.gms/app_chimera/m/00000000/DynamiteModules-prod.apk': Failed to open oat filename for reading: No such file or directory
  03-30 20:58:28.880 17076-17076/com.tremulant.phield D/ChimeraFileApk: Classloading successful. Optimized code found.
  03-30 20:58:29.044 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services client version: 8487000
  03-30 20:58:29.055 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  03-30 20:58:29.331 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  03-30 20:58:29.339 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  03-30 20:58:29.344 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  03-30 20:58:29.352 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  03-30 20:58:29.361 17076-17076/com.tremulant.phield I/Google Maps Android API: Google Play services package version: 8703230
  </code></pre>