Search code examples
androidandroid-activitynullpointerexceptionandroid-fragmentsactivity-lifecycle

Why is NPE thrown when finishing Activity?


I have an error that has been driving me crazy for days. Unfortunately, I can not show you the code for two reason, my boss will not appreciate it and the codebase is too large to share. The error occurs whenever the Activity is finishing. Weather it be because I call finish() or because the os destroys it.

The question is, what is (or could) cause execPendingActions() in FragmentManagerImpl to throw a NPE at line 1196.

Here is the stacktrace:

FragmentManagerImpl.execPendingActions() line: 1196 
FragmentManagerImpl$1.run() line: 375   
Handler.handleCallback(Message) line: 587   
Handler.dispatchMessage(Message) line: 92   
Looper.loop() line: 126 
ActivityThread.main(String[]) line: 3997    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 491  
ZygoteInit$MethodAndArgsCaller.run() line: 841  
ZygoteInit.main(String[]) line: 599 
NativeStart.main(String[]) line: not available [native method]  

Solution

  • You could try using the compat library and debugging that.

    Alternatively try and reproduce in a cut down sample app.