title: I want to show multiple location in Android Google Map Activity
body: <p>I want to show multiple location in Android Google Map Activity, But cannot it for the reason application crash. Error Show in Logcat , *</p>
  
  <blockquote>
    <p><strong>Can Any One solve it or give any multiple google Map location using JSON API for Android</strong></p>
  </blockquote>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{daffodilvarsity.edu.bd.studentportal/daffodilvarsity.edu.bd.studentportal.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.MapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
  </code></pre>
  
  <p>Here is Error from Logcat:</p>
  
  <pre><code>08-18 11:30:47.044 4324-4324/daffodilvarsity.edu.bd.studentportal D/ChimeraFileApk: Primary ABI of requesting process is x86_64
  08-18 11:30:47.044 4324-4324/daffodilvarsity.edu.bd.studentportal D/ChimeraFileApk: Classloading successful. Optimized code found.
  08-18 11:30:47.055 4324-4324/daffodilvarsity.edu.bd.studentportal I/Google Maps Android API: Google Play services client version: 9452000
  08-18 11:30:47.056 4324-4324/daffodilvarsity.edu.bd.studentportal I/Google Maps Android API: Google Play services package version: 9452480
  08-18 11:30:47.089 4324-4324/daffodilvarsity.edu.bd.studentportal I/c: Token loaded from file. Expires in: 370172650 ms.
  08-18 11:30:47.089 4324-4324/daffodilvarsity.edu.bd.studentportal I/c: Scheduling next attempt in 369872 seconds.
  08-18 11:30:47.136 4324-4324/daffodilvarsity.edu.bd.studentportal D/AndroidRuntime: Shutting down VM
  08-18 11:30:47.137 4324-4324/daffodilvarsity.edu.bd.studentportal E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                    Process: daffodilvarsity.edu.bd.studentportal, PID: 4324
                                                                                     java.lang.RuntimeException: Unable to start activity  ComponentInfo{daffodilvarsity.edu.bd.studentportal/daffodilvarsity.edu.bd. studentportal.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.MapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
                                                                                       at  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                      at android.os.Looper.loop(Looper.java:148)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.MapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
                                                                                      at daffodilvarsity.edu.bd.studentportal.MapsActivity.onCreate(MapsActivity.java:53)
                                                                                      at android.app.Activity.performCreate(Activity.java:6237)
                                                                                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                      at android.os.Looper.loop(Looper.java:148) 
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>
  
  <p>Here is My XML file : <strong>activity_maps.xml</strong></p>
  
  <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/map"
  android:name="com.google.android.gms.maps.SupportMapFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
   tools:context="daffodilvarsity.edu.bd.studentportal.LocationShareMapsActivity" /&gt;
  </code></pre>
  
  <p>This is <strong>AndroidManifest.xml</strong> file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="daffodilvarsity.edu.bd.studentportal"&gt;
  
  &lt;uses-feature
      android:glEsVersion="0x00020000"
      android:required="true" /&gt; 
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission  android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PROFILE" /&gt;
  
  &lt;application
      android:name="android.support.multidex.MultiDexApplication"
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MapsActivity"
          android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>This is <strong>Build.gradle</strong> file</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 23
  buildToolsVersion "24.0.1"
  useLibrary 'org.apache.http.legacy'
  
  dexOptions {
      incremental true
      javaMaxHeapSize "2048M"
  }
  
  defaultConfig {
      applicationId "daffodilvarsity.edu.bd.studentportal"
      minSdkVersion 14
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
  
      // Enabling multidex support.
      multiDexEnabled true
  
  }
  packagingOptions {
      exclude 'META-INF/XXX'
      exclude 'META-INF/DEPENDENCIES.txt'
      exclude 'META-INF/NOTICE'
      exclude 'META-INF/NOTICE.txt'
      exclude 'META-INF/LICENSE'
      exclude 'META-INF/LICENSE.txt'
  }
  
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }
  }
  
  dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  
  compile 'com.android.support:multidex:1.0.1'
  compile 'com.android.support:appcompat-v7:23.4.0'
  compile 'com.android.support:design:23.4.0'
  compile 'com.google.android.gms:play-services:9.4.0'
  compile 'com.google.android.gms:play-services-maps:9.4.0'
  }
  </code></pre>
  
  <p>This Is java file: <strong>MapsActivity.java</strong> file</p>
  
  <pre><code>package daffodilvarsity.edu.bd.studentportal;
  
  import android.support.v4.app.FragmentActivity;
  import android.os.Bundle;
  import android.util.Log;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.OnMapReadyCallback;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.URL;
  
  public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  private static final String LOG_TAG = "ExampleApp";
  
  private static final String SERVICE_URL = "https://api.myjson.com/bins/4jb09";
  
  protected GoogleMap map;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_maps);
      if (map == null) {
  
          MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
  
          if (map != null) {
              setUpMap();
          }
      }
      //setUpMapIfNeeded();
   }
  
   private void setUpMap() {
      // Retrieve the city data from the web service
      // In a worker thread since it's a network operation.
      new Thread(new Runnable() {
          public void run() {
              try {
                  retrieveAndAddCities();
              } catch (IOException e) {
                  Log.e(LOG_TAG, "Cannot retrive cities", e);
                  return;
              }
          }
      }).start();
   }
  
   protected void retrieveAndAddCities() throws IOException {
      HttpURLConnection conn = null;
      final StringBuilder json = new StringBuilder();
      try {
          // Connect to the web service
          URL url = new URL(SERVICE_URL);
          conn = (HttpURLConnection) url.openConnection();
          InputStreamReader in = new InputStreamReader(conn.getInputStream());
  
          // Read the JSON data into the StringBuilder
          int read;
          char[] buff = new char[1024];
          while ((read = in.read(buff)) != -1) {
              json.append(buff, 0, read);
          }
      } catch (IOException e) {
          Log.e(LOG_TAG, "Error connecting to service", e);
          throw new IOException("Error connecting to service", e);
      } finally {
          if (conn != null) {
              conn.disconnect();
          }
      }
  
      // Create markers for the city data.
      // Must run this on the UI thread since it's a UI operation.
      runOnUiThread(new Runnable() {
          public void run() {
              try {
                  createMarkersFromJson(json.toString());
              } catch (JSONException e) {
                  Log.e(LOG_TAG, "Error processing JSON", e);
              }
          }
      });
    }
  
   void createMarkersFromJson(String json) throws JSONException {
      // De-serialize the JSON string into an array of city objects
      JSONArray jsonArray = new JSONArray(json);
      for (int i = 0; i &lt; jsonArray.length(); i++) {
          // Create a marker for each city in the JSON data.
          JSONObject jsonObj = jsonArray.getJSONObject(i);
          map.addMarker(new MarkerOptions()
                  .title(jsonObj.getString("name"))
                  .snippet(Integer.toString(jsonObj.getInt("population")))
                  .position(new LatLng(
                          jsonObj.getJSONArray("latlng").getDouble(0),
                          jsonObj.getJSONArray("latlng").getDouble(1)
                  ))
          );
      }
   }
  
  @Override
  public void onMapReady(GoogleMap googleMap) {
  
      try {
          createMarkersFromJson(SERVICE_URL);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
  }
  }
  </code></pre>