Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android NullPointerException crash #354

Closed
wants to merge 1 commit into from

Conversation

Passer-by
Copy link

Fixed #350 , #347 , #345 .

Crash reason: mMethodChannel is destroyed following the lifecycle of the Activity hosting Flutter. Specifically, it’s set to null in the onDetachedFromEngine method. However, AppsFlyerLib appears to be a singleton, meaning its callback timing aligns with the entire app's lifecycle, which creates a chance for mMethodChannel 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.

@Passer-by
Copy link
Author

Additionally, mCallbackChannel has a similar potential issue, but it does not cause a crash because it is never actually destroyed correctly. Finally, mEventChannel seems to serve no purpose; it might be a draft.

@Passer-by Passer-by changed the title fix issue#350 Fix issue#350 Oct 28, 2024
@Passer-by Passer-by changed the title Fix issue#350 Fix Android NullPointerException crash Oct 28, 2024
@Dani-Koza-AF
Copy link
Collaborator

Dani-Koza-AF commented Oct 30, 2024

Thanks! seems like indeed this is the core of the problem. As for your additional notes, I will take care of it and remove it if It is redundant.
In the future please open PR's into development branch :)
Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

com.appsflyer.appsflyersdk.AppsflyerSdkPlugin$5$2.run(AppsflyerSdkPlugin.java:402)
2 participants