--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/Jqjc7uwqkjEJ.
To post to this group, send email to robo...@googlegroups.com.
To unsubscribe from this group, send email to roboguice+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/roboguice?hl=en.
Manfred - I'm also having issues with another project where injection is failing on an activity and giving me the @Nulable error as well. Not sure what's causing it
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/4f0-MDtaLPgJ.
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.jav a:226)
> at android.app.Activity.setContentView(Activity.java:1780)
> at
> com.somewhere.mobile.activity.RootFragmentActivity.onCreate(RootFragmentAct ivity.java:46)
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
When the screen is rotated and a Fragment was added to the previous
instance of the Activity, the new Activity gets that Fragment attached
to it automatically when it's being created.
ViewMembersInjector.injectMembers then adds the injectable members of
the Fragment directly to the Activity (in the first half of the
method) and then adds the injectable members again to the Fragment in
the second half of the method. If setContentView is then called from
the Activity's onCreate, onContentChanged ends up being called before
the Fragment has had onCreateView called on it. The Fragment's view
is not created, and therefore we get a crash when the its views are
injected. What I'm uncertain of is WHY the Fragments' members are
being attached to the Activity at all. Is this to support Fragments
that have @InjectView annotations but are NOT RoboFragments?
As a temporary work-around, I created a new marker interface
InjectsOwnViews and had all of the Robo versions of the Fragment
classes (RoboFragment, RoboListFragment, RoboDialogFragment) implement
it. When ViewMembersInjector.injectMembers is then called, it ignores
any fragments that implement InjectsOwnViews. The Fragment's view
injection is then delayed until after its onCreateView method is
called, as we would expect.
What I can't figure out is why this makes a difference if the Fragment
was attached to the Activity's view hierarchy directly (non-
programmatically) or when it's later attached programmatically. The
approach that I tried appears to work for both cases. It's possible
that the first half of the ViewMembersInjector method was NEVER
intended to be used on Fragments at all. Can anybody who understands
this better let us know? If this is the case, the solution to this
problem is literally a single line. Just wrap the first half of
ViewMembersInjector.injectMembers with
if ( ! (instance instanceof Fragment) ) {
...
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/R4Floj2y9ygJ.
http://dl.dropbox.com/u/4723421/fragmentrotation.zip
I hope this is the same case reported first in this thread.
On 11 Des, 16:21, Michael Burton <m...@niskala.org> wrote:
> Cherry, I'm wondering whether my example below is exposing the same issue that you're seeing. Here's the crash I get, is this the same one you're seeing?
>
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.roboguice.astroboy/org.roboguice.astroboy.activity.AstroF ragmentActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment org.roboguice.astroboy.fragment.Fragment1$1$1: make sure class name exists, is public, and has an empty constructor that is public
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2832)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.access$1600(ActivityThread.java:117)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.os.Handler.dispatchMessage(Handler.java:99)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.os.Looper.loop(Looper.java:130)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.main(ActivityThread.java:3683)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at java.lang.reflect.Method.invokeNative(Native Method)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at java.lang.reflect.Method.invoke(Method.java:507)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 839)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at dalvik.system.NativeStart.main(Native Method)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment org.roboguice.astroboy.fragment.Fragment1$1$1: make sure class name exists, is public, and has an empty constructor that is public
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.support.v4.app.Fragment.instantiate(Fragment.java:388)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.support.v4.app.FragmentState.instantiate(Fragment.java:96)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager. java:1662)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:192)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at roboguice.activity.RoboFragmentActivity.onCreate(RoboFragmentActivity.java: 41)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): ... 12 more
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): Caused by: java.lang.InstantiationException: org.roboguice.astroboy.fragment.Fragment1$1$1
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at java.lang.Class.newInstanceImpl(Native Method)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at java.lang.Class.newInstance(Class.java:1409)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
> 11-01 06:50:21.575 E/AndroidRuntime( 4119): ... 18 more
>
> --http://about.me/michaelburton
>
> On Dec 11, 2011, at 12:04 PM, Michael Burton wrote:
>
>
>
>
>
>
>
> > Ah, never mind. I was able to repro the issue by modifying Astroboy to follow Cherry Development's steps outline below.
>
> > Here's the project that will crash on screen rotation after you click the two buttons
>
> >http://cl.ly/10293J2f1e1b1p3r2t33
>
> > Mike
>
> > --
> >http://about.me/michaelburton
>
> > On Dec 10, 2011, at 4:32 PM, Michael Burton wrote:
>
> >> I'm trying to follow along on this thread, but I don't have an example that reproduces the problem. Does anyone think they can supply a small project or testcase that demonstrates the problem?
>
> >> --
> >>http://about.me/michaelburton
>
> >> On Dec 9, 2011, at 9:38 PM, Cherry Development wrote:
>
> >>> The following behaviour seems to be working for me:
>
> >>> RoboFragmentActivity that starts with no fragments attached.
> >>> A button attaches a RoboFragment that's added to the back stack.
> >>> A button on the fragment pops up a RoboDialogFragment.
>
> >>> Rotate the screen:
>
> >>> All elements are the way they're supposed to be.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "roboguice" group.
> >>> To view this discussion on the web visithttps://groups.google.com/d/msg/roboguice/-/R4Floj2y9ygJ.
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/3g-Aq0hxIXcJ.
Of course, Manfred... always gotta be a party pooper ... :)
Sent via Android
On 20 Des, 00:46, Michael Burton <m...@niskala.org> wrote:
> Okay, I see the problem. Filed ashttp://code.google.com/p/roboguice/issues/detail?id=166 Fixed, the latest snapshot should resolve the issue for the code that daniel posted.
Hi there,I've got the same issue. With RoboGuice 2.0 Beta 3 I've got the Exception "java.lang.NullPointerException: Can't inject null value into class foo.bar.fragment.Myragment.buttonTest when field is not @Nullable"Now I've upgraded to the latest Snapshot. The Exception is gone. Fine. But if I change the orientation all my private injected fields (via @InjectView) are now null. This only happens on screen orientation change. Before I change the orientation all private fields are injected fine.Any ideas?
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/_pqvvWpn1_sJ.
Done. Issue 183 (http://code.google.com/p/roboguice/issues/detail?id=183)
2012/2/24 Michael Burton <mi...@niskala.org>: