Note that there are some explanatory texts on larger screens.

plurals
  1. POgoogle mapv2 null pointer exception
    text
    copied!<p>my code is working fine, when i my trying to display the map,but when i access the googlemap object then it through null pointer exception, so how to overcome it please help</p> <p>i had followed all the instruction on developer site, here is my code</p> <pre><code>package com.example.mapdemo; import java.io.IOException; import java.util.List; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap.OnMapClickListener; import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener; import com.google.android.gms.maps.GoogleMap.OnMarkerDragListener; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import android.content.Context; import android.location.Address; import android.location.Geocoder; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends FragmentActivity { GoogleMap googleMap; MarkerOptions markerOptions; final int RQS_GooglePlayServices = 1; TextView tvLocInfo; boolean markerClicked; Button img_cancl,img_done; static final LatLng HAMBURG = new LatLng(53.558, 9.927); static final LatLng KIEL = new LatLng(53.551, 9.993); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (resultCode == ConnectionResult.SUCCESS) { Toast.makeText(getApplicationContext(), "isGooglePlayServicesAvailable SUCCESS", Toast.LENGTH_LONG).show(); map.addMarker(new MarkerOptions().position(new LatLng(53.558, 9.927)).title("Marker")); Log.i("testing", "success"); } else { GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices); Log.i("testing", "errorrrrrrrrr"); } } } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (resultCode == ConnectionResult.SUCCESS){ Toast.makeText(getApplicationContext(), "isGooglePlayServicesAvailable SUCCESS", Toast.LENGTH_LONG).show(); }else{ GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices); } } } </code></pre> <p>here is my layout</p> <blockquote> <p> </p> <pre><code>&lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" &gt; &lt;TextView android:id="@+id/tvLocInfo" android:layout_width="fill_parent" android:layout_height="50dp" /&gt; &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="40dp" class="com.google.android.gms.maps.SupportMapFragment" /&gt; &lt;/RelativeLayout&gt; &lt;include layout="@layout/lay_button" /&gt; </code></pre> <p></p> </blockquote> <p>manifest file</p> <blockquote> <p> </p> <pre><code>&lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /&gt; &lt;permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature"/&gt; &lt;uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; &lt;uses-feature android:glEsVersion="0x00020000" android:required="true"/&gt; &lt;application android:debuggable="true" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.mapdemo.MainActivity" 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;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBd0XLtX5eHnpHJ7g2XsQ6sntNjDxuS6i4"/&gt; &lt;/application&gt; </code></pre> <p></p> </blockquote> <p>Here is logcat</p> <p>07-24 10:00:29.051: I/testing(2825): errorrrrrrrrr</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload