Skip to content

Conversation

@ilous12
Copy link

@ilous12 ilous12 commented Oct 30, 2025

I’m reaching out regarding two critical issues in the appsflyer-flutter-plugin on Android, specifically related to startSDK() behavior when the app is terminated via the Back key and then re-launched.

Issue Summary

  • When the app is terminated using the Back key, the native AppsFlyer SDK singleton instance remains active, but the Flutter plugin channel becomes detached.
  • Calling startSDK() again upon re-launch results in unexpected behavior — the SDK fails to initialize properly, and callbacks (e.g., deep linking, attribution) are not triggered.

Reproduction Steps

  • Launch the Android app for the first time → call startSDK()
  • Press the Back key from the root screen → app process is killed
  • Re-launch the app from the launcher → call startSDK() again

→ Result: SDK does not function correctly on the second start.

Root Cause

  • Native SDK (AppsFlyerLib): Singleton persists after process kill
  • Flutter Plugin: Method channel is detached → cannot communicate with native layer
  • On re-launch, startSDK() assumes a clean state, but the native layer is already initialized → state mismatch

Fix Implemented (PR #424)
I’ve submitted a pull request that resolves this issue:
PR Link:
Changes:

Added a runtime check to detect if the native SDK is already running
Modified startSDK() to return success/failure based on current state
Prevents redundant initialization and avoids crashes due to detached channel
Ensures reliable behavior even after Back key termination

Request
Could you please review and consider merging this PR?

  • It directly addresses a reproducible and high-impact issue affecting Android users on cold restarts.
  • I’ve included detailed comments in the PR and tested across multiple devices (emulators + physical).

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.

1 participant