Fix Android NullPointerException crash #354
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed #350 , #347 , #345 .
Crash reason:
mMethodChannel
is destroyed following the lifecycle of theActivity
hosting Flutter. Specifically, it’s set to null in theonDetachedFromEngine
method. However,AppsFlyerLib
appears to be a singleton, meaning its callback timing aligns with the entire app's lifecycle, which creates a chance formMethodChannel
to be null.Crash scenario: This is a hypothetical situation. Before the callback for
AppsFlyerLib.start
executes, the app navigates to a non-Flutter Activity (like in an advertisement scene). At this point, the previous Flutter-hosting Activity is destroyed, possibly due to low memory.