DMCApps / NavigationFragment

The purpose of this manager is to work with the ViewPager, Tabs and Navigation drawer to handle a single stack flow of fragments on the screen. It makes use of a main Fragment as a container and presents and hides fragments within it as children.
MIT License
28 stars 8 forks source link

new bug on nextAnim #19

Closed jjhesk closed 8 years ago

jjhesk commented 8 years ago

This is found from the MotoG3 machine

DEVICE MotoG3 DEVICE Portrait ORIENTATION Off PROXIMITY N/A BATTERY OPERATING SYSTEM 6.0 ANDROID VERSION No ROOTED Portrait UI ORIENTATION

@DMCApps

Fatal Exception: java.lang.NullPointerException: Attempt to write to field 'int android.support.v4.app.Fragment.mNextAnim' on a null object reference
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:726)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
       at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
       at android.os.Handler.handleCallback(Handler.java:746)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5443)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
DMCApps commented 8 years ago

Hey @jjhesk,

Sorry about the issue and thank you for the continued support.

I've had this a few times. It seems to depend on the timing of when you call present or dismiss (e.g. calling it in say onCreate vs onResume, not that I have had this as a crash in that base but just as an example). I can't nail down exactly what it is, but it seems that there is something in the android system itself that when calling present or dismiss isn't set.

Basically if you try and do the present at a later time in the code it should be a work around for this issue, again I'm not certain the nature of the issue but it has to do with the point at which you are presenting and dismissing (basically adding/removing fragments from the FragmentManager.

jjhesk commented 8 years ago

@DMCApps I have found another error from the restart of the activity. I want to know if there has anything to deal with your update on com.dmcapps:navigation-fragment:0.2.0.2

FATAL EXCEPTION: main Process: cy.mh520, PID: 5686 java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:617) at com.dmcapps.navigationfragment.manager.micromanagers.stack.StackManager.popFragment(StackManager.java:46) at com.dmcapps.navigationfragment.manager.NavigationManagerFragment.popFragment(NavigationManagerFragment.java:156) at com.dmcapps.navigationfragment.manager.NavigationManagerFragment.popFragment(NavigationManagerFragment.java:143) at com.dmcapps.navigationfragment.fragments.NavigationFragment.dismissFragment(NavigationFragment.java:62)

and this is another bug from using this implementation

Process: n18.a0.x5.debug.debug, PID: 23701 java.lang.RuntimeException: Unable to start activity ComponentInfo{n18.a0.x5.debug.debug/hx520.hxhx.main.MainTabNew}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.dmcapps.navigationfragment.manager.SingleStackNavigationManagerFragment: make sure class name exists, is public, and has an empty constructor that is public at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.dmcapps.navigationfragment.manager.SingleStackNavigationManagerFragment: make sure class name exists, is public, and has an empty constructor that is public at android.support.v4.app.Fragment.instantiate(Fragment.java:431) at android.support.v4.app.FragmentState.instantiate(Fragment.java:102) at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1952) at android.support.v4.app.FragmentController.restoreAllState(FragmentController.java:144) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:306) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85) at hx520.hxhx.main.navBase.onCreate(navBase.java:63) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  Caused by: java.lang.InstantiationException: class com.dmcapps.navigationfragment.manager.SingleStackNavigationManagerFragment has no zero argument constructor

DMCApps commented 8 years ago

Does it possibly have anything to do with this?

http://stackoverflow.com/a/14222708/845038

There was a very very small change from 0.2.0.1 to 0.2.0.2 ... Can you revert to 0.2.0.1 and see if the crash still happens? If that seems to fix it by reverting to 0.2.0.1 then I can remove the line causing the issue. Based on the stack trace though it doesn't look like the code that I added would be causing the issue.

Let me know the results of the above items to try.

jjhesk commented 8 years ago

I will try to test it on different versions in android.

Also there was bugs causing from using app Android API 4.4.2.. something related to fragment instance didnt clear or leak. would you cover that form my snipplet?