0
Good morning!
I have the following code to load the map in my application:
if (mMap == null){
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if(null == mMap)
{
SupportMapFragment fragment = SupportMapFragment.class.cast(getSupportFragmentManager().findFragmentById(R.id.map));
fragment.onCreate(savedInstanceState);
fragment.getMapAsync(this);
}
}
XML:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Apparently, the tests worked correctly, there was no error loading, but I’m getting several failures in the google play.:
java.lang.NullPointerException: Attempt to read from field 'com.google.android.gms.maps.model.LatLng com.google.android.gms.maps.model.MarkerOptions.b' on a null object reference
at com.google.maps.api.android.lib6.d.et.a(Unknown Source)
at com.google.android.gms.maps.internal.j.onTransact(SourceFile:167)
at android.os.Binder.transact(Binder.java:395)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addMarker(Unknown Source)
at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
The NullPointerException
occurs because, when trying to add the Marker to the map, it is null.
I treated the problem so that the NullPointerException
, but would like to know why the map is not loaded?
From what I noticed, occur in all versions of Android (from 4.0 to 5.1), It is nothing specific of a version.
There are other ways to load the map?
Thanks in advance !
Greetings