android10 / Android-CleanArchitecture

This is a sample app that is part of a series of blog posts I have written about how to architect an android application using Uncle Bob's clean architecture approach.
Apache License 2.0
15.52k stars 3.32k forks source link

NullPointerException on UserListFragment is being recreated with Don't keep Activities #144

Open farmazon3000 opened 8 years ago

farmazon3000 commented 8 years ago

Scenario:

05-09 16:26:44.956 24604-24604/com.fernanependocejas.android10.sample.presentation E/AndroidRuntime: FATAL EXCEPTION: main Process: com.fernanependocejas.android10.sample.presentation, PID: 24604 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fernanependocejas.android10.sample.presentation/com.fernandocejas.android10.sample.presentation.view.activity.UserDetailsActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.fernandocejas.android10.sample.presentation.internal.di.components.UserComponent.inject(com.fernandocejas.android10.sample.presentation.view.fragment.UserDetailsFragment)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) at android.app.ActivityThread.access$900(ActivityThread.java:150) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.fernandocejas.android10.sample.presentation.internal.di.components.UserComponent.inject(com.fernandocejas.android10.sample.presentation.view.fragment.UserDetailsFragment)' on a null object reference at com.fernandocejas.android10.sample.presentation.view.fragment.UserDetailsFragment.onCreate(UserDetailsFragment.java:48) at android.app.Fragment.performCreate(Fragment.java:2198) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:942) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130) at android.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1948) at android.app.FragmentController.dispatchCreate(FragmentController.java:141) at android.app.Activity.onCreate(Activity.java:924) at com.fernandocejas.android10.sample.presentation.view.activity.BaseActivity.onCreate(BaseActivity.java:22) at com.fernandocejas.android10.sample.presentation.view.activity.UserDetailsActivity.onCreate(UserDetailsActivity.java:37) at android.app.Activity.performCreate(Activity.java:6248) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)  at android.app.ActivityThread.access$900(ActivityThread.java:150)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:168)  at android.app.ActivityThread.main(ActivityThread.java:5845)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 

This may be related to #92.

farmazon3000 commented 8 years ago

It happens also on Users List Activity so it's not UserListFragment but general problem.

FizzyMobile commented 8 years ago

Check out issue https://github.com/android10/Android-CleanArchitecture/issues/124 for more info, and also this PR https://github.com/android10/Android-CleanArchitecture/pull/134.