0

I've uploaded an APK update to Google Store, and I saw a drastic increase in crashes(all of them on android 5) , Crashlytics points me to :

BackStackRecord.java line 797
android.app.BackStackRecord.run

and then says:

Non-fatal Exception: java.lang.NullPointerException
Attempt to write to field 'int android.app.Fragment.mNextAnim' on a null object reference
android.app.BackStackRecord.run (BackStackRecord.java:797)
android.os.Looper.loop (Looper.java:145)
android.app.ActivityThread.main (ActivityThread.java:5832)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)

The changes I've made since the last version are minor and except a few "cosmetic" changes I've only added a few lines to work with the Facebook SDK.

BVtp
  • 2,308
  • 2
  • 29
  • 68

1 Answers1

1

This error is common when you try to use the FragmentTransaction on a null pointer. As an example, when doing: fragmentTransaction.hide(fm.findFragmentByTag("yourfragmenttag")); without checking if your fragment exists or not.

Try to check that you are not working with fragment which are not yet initialized, or that you already removed.

To see more: Android FragmentManager BackStackRecord.run throwing NullPointerException

Community
  • 1
  • 1
Virthuss
  • 3,142
  • 1
  • 21
  • 39
  • the things is that I have around 20 different commit()/remove() .. How can I detect where the problem really happens? – BVtp Oct 29 '15 at 06:44
  • 1
    The thing is you cannot from the APK directly. The best for you would be to have a specific use case leading to the crash, allowing you to protect the incriminate part of the code. The error will happen not during the commit() but typically when you call the show(), hide()... or whatever method taking a fragment as a parameter. The fragment being null, it means you probably try to pass a fragment as a parameter which is null as you call it from its tag. What you can do is storing the the fragment you try to call this way on an object and test its value, null or not, before making an use of it. – Virthuss Oct 29 '15 at 06:47