Fragment support is still quite incomplete, especially when inflating fragments from xml. I'd suggest either taking a stab at debugging the problem, or changing your app to instantiate your fragments in code rather than using the fragment tag in xml (we've done quite a bit more testing of robolectric with this style of fragments use).
Maybe someone using fragments in a current project can comment further?
--Aaron V.
It's been a while since I worked on in, but I believe when inflating fragments from xml, there will be no container view at the point of code you indicated. Instead, the inflation code (ViewLoader?) attaches the fragment's view to the view hierarchy after the fragment has been initialized.
The lifecycle for fragment inflation is somewhat incorrect as it currently stands: real Android creates the fragments in an uninitialized state during inflation and runs the on* lifecycle methods when the corresponding methods of the FragmentActivity are called. In contrast, robolectric currently calls many of the lifecycle methods *during* inflation. I don't know if this is related to what you are seeing, but if it is, TestFragmentManager will need to become a bit more sophisticated to behave more exactly like Android.
--Aaron V.
java.lang.RuntimeException: error inflating layout/activity_gmm at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:106) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:82) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:86) at com.xtremelabs.robolectric.res.ResourceLoader.inflateView(ResourceLoader.java:372) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:43) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:48) at android.view.LayoutInflater.inflate(LayoutInflater.java) at com.xtremelabs.robolectric.shadows.ShadowActivity.setContentView(ShadowActivity.java:102) at android.app.Activity.setContentView(Activity.java)
Caused by: java.lang.NullPointerException at com.xtremelabs.robolectric.bytecode.RobolectricClassLoader.loadClass(RobolectricClassLoader.java:54
) at com.xtremelabs.robolectric.res.ViewLoader.loadClass(ViewLoader.java:261) at com.xtremelabs.robolectric.res.ViewLoader.loadFragmentClass(ViewLoader.java:274) at com.xtremelabs.robolectric.res.ViewLoader.constructFragment(ViewLoader.java:192) at com.xtremelabs.robolectric.res.ViewLoader.create(ViewLoader.java:174) at com.xtremelabs.robolectric.res.ViewLoader.inflate(ViewLoader.java:150) at com.xtremelabs.robolectric.res.ViewLoader.inflate(ViewLoader.java:153) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:102) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:82) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:86) at com.xtremelabs.robolectric.res.ResourceLoader.inflateView(ResourceLoader.java:372) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:43) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.xtremelabs.robolectric.bytecode.ShadowWrangler.methodInvoked(ShadowWrangler.java:99) at com.xtremelabs.robolectric.bytecode.RobolectricInternals.methodInvoked(RobolectricInternals.java:111) at android.view.LayoutInflater.inflate(LayoutInflater.java) at com.xtremelabs.robolectric.shadows.ShadowActivity.setContentView(ShadowActivity.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.xtremelabs.robolectric.bytecode.ShadowWrangler.methodInvoked(ShadowWrangler.java:99) at com.xtremelabs.robolectric.bytecode.RobolectricInternals.methodInvoked(RobolectricInternals.java:111) at android.app.Activity.setContentView(Activity.java)
Warning: an error occurred while binding shadow class: ShadowGeoPoint Warning: an error occurred while binding shadow class: ShadowItemizedOverlay Warning: an error occurred while binding shadow class: ShadowMapController Warning: an error occurred while binding shadow class: ShadowMapActivity Warning: an error occurred while binding shadow class: ShadowMapView Warning: an error occurred while binding shadow class: ShadowOverlayItem WARNING: Unable to find path to Android SDK
Exception in thread "Thread-1" java.lang.RuntimeException: java.io.FileNotFoundException: /.../workspace/75f9c8e32bf7255ed0bca1d210550685/2f2babb5-87c5-408b-85ad-b8e0c0b19222/.../gcc-4.6.x-glibc-2.11.1-grte-cxx11-k8-opt/bin/..././tmp/cached-robolectric-classes.jar (No such file or directory) at com.xtremelabs.robolectric.bytecode.ClassCache.saveAllClassesToCache(ClassCache.java:118) at com.xtremelabs.robolectric.bytecode.ClassCache.run(ClassCache.java:55) Caused by: java.io.FileNotFoundException: /.../workspace/75f9c8e32bf7255ed0bca1d210550685/2f2babb5-87c5-408b-85ad-b8e0c0b19222/.../gcc-4.6.x-glibc-2.11.1-grte-cxx11-k8-opt/bin/..././tmp/cached-robolectric-classes.jar (No such file or directory)
at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:209) at java.io.FileOutputStream.<init>(FileOutputStream.java:160) at com.xtremelabs.robolectric.bytecode.ClassCache.saveAllClassesToCache(ClassCache.java:110)
Caused by: java.lang.ClassCastException: com.xxx.MyFragment cannot be cast to android.support.v4.app.Fragment at com.xtremelabs.robolectric.res.ViewLoader.constructFragment(ViewLoader.java:193) at com.xtremelabs.robolectric.res.ViewLoader.create(ViewLoader.java:174) at com.xtremelabs.robolectric.res.ViewLoader.inflate(ViewLoader.java:150) at com.xtremelabs.robolectric.res.ViewLoader.inflate(ViewLoader.java:153) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:102) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:82) at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:86) at com.xtremelabs.robolectric.res.ResourceLoader.inflateView(ResourceLoader.java:372) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:43) at com.xtremelabs.robolectric.shadows.ShadowLayoutInflater.inflate(ShadowLayoutInflater.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.xtremelabs.robolectric.bytecode.ShadowWrangler.methodInvoked(ShadowWrangler.java:99) at com.xtremelabs.robolectric.bytecode.RobolectricInternals.methodInvoked(RobolectricInternals.java:111) at android.view.LayoutInflater.inflate(LayoutInflater.java) at com.xtremelabs.robolectric.shadows.ShadowActivity.setContentView(ShadowActivity.java:102)
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "Robolectric" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robolectric/A1oJ_jtIRSI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to robolectric...@googlegroups.com.