Good morning!
I have the following code to load the map into my app:
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 play.google :
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 on the map, it is null.
I tried the problem so that NullPointerException
does not occur, but would you like to know why the map is not loaded?
From what I've noticed, they occur in all versions of Android (from 4.0 to 5.1), it's nothing specific to a version.
Are there other ways to load the map?
Thank you in advance!
Greetings