1

I get a NullPointerException when trying to start fragment in Roboeltric -

java.lang.NullPointerException
at com.google.android.gms.common.internal.zzh.zzaT(Unknown Source)
at com.google.android.gms.common.internal.zzh.zzaT(Unknown Source)
at com.google.android.gms.common.internal.zzh.zzi(Unknown Source)
at com.google.android.gms.common.internal.zzh.zzi(Unknown Source)

The fragment contains a SupportMapFragment, here is the XML:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/recyclerVenue"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:id="@+id/map" />

The SupportMapFragment is in a fragment (android.support.v4.app.Fragment) as well

@Before
public void setUp() {
    mapFragment = new MapFragment();
    startFragment(mapFragment); // Crashes here
}

Changing the FrameLayout to fragment causes the sorry not implemented message. Can someone point me in the right direction since it works when running on device/emulator? thanks

Rob Deans
  • 75
  • 1
  • 9
  • You can't just nest fragments. You can create child fragments using supportChildFragmentManager. See http://stackoverflow.com/questions/6672066/fragment-inside-fragment – Christine Mar 19 '17 at 21:06
  • it works on the actual device though? its just testing gives me the problem, in the actual implementation I am using getChildFragmentManager – Rob Deans Mar 19 '17 at 22:25
  • Robolectric has shadow implementations of most Android stuff. "sorry not implemented" probably means that Robolectric doesn't provide an implementation for the method you call. You can try going throug the Robolectric code using the debugger, then you'll see where exactly the "not implemented" occurs. Then you read the Robolectric source. – Christine Mar 19 '17 at 22:39
  • Do you use `org.robolectric:shadows-maps`? – Eugen Martynov Mar 21 '17 at 08:21
  • Yeah I do use that (version 3.3.1) – Rob Deans Mar 21 '17 at 18:49

0 Answers0