Skip to content

Conversation

congfandi
Copy link

PR Title:
[Android] Fix fatal crash in ChannelManager.invokeChannelMethod when notImplemented is called
PR Description:
markdown## Description
Fixes a critical crash that occurs when MethodChannel.Result.notImplemented() is triggered in ChannelManager.invokeChannelMethod(). The current implementation throws a fatal Error which immediately crashes the app, making several methods unusable.

Problem

The current implementation in ChannelManager.kt line 75 throws a fatal error:

override fun notImplemented() {
    throw Error("Critical Error: invokeMethod $methodName notImplemented ")
}
This causes immediate app crashes with errors like:
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: java.lang.Error: Critical Error: invokeMethod TapjoyOnGetCurrencyBalanceFailure notImplemented
E/AndroidRuntime: at com.tapjoy.flutter.ChannelManager$invokeChannelMethod$1$1.notImplemented(ChannelManager.kt:75)
Root Cause
The issue occurs when there are minor timing or communication issues between Flutter and Android method channels. Instead of handling these gracefully, the current code kills the entire app.
Solution
Replace the fatal throw Error() with a warning log that allows the app to continue running:
kotlinoverride fun notImplemented() {
    Log.w(TAG, "Warning: invokeMethod $methodName notImplemented")
}
Impact
Before Fix:App crashes immediately when method channel has issues
❌ getCurrencyBalance() method completely unusable
❌ Poor user experience with unexpected crashes
❌ Makes several Tapjoy features unreliable

After Fix:App continues running even with method channel issues
✅ getCurrencyBalance() and other methods work reliably
✅ Graceful degradation instead of crashes
✅ Developers can still see warnings in logs for debugging
✅ Improved app stability and user experience

Testing

 Tested getCurrencyBalance() method on Android
 Verified app no longer crashes with method channel issues
 Confirmed warning logs appear correctly in logcat
 Validated that successfully implemented methods continue to work normally
 No impact on iOS implementation

Backward CompatibilityNo breaking changes
✅ Existing functionality preserved
✅ Only affects error handling behavior

Files Changed

android/src/main/kotlin/com/tapjoy/flutter/ChannelManager.kt (1 line)

Related Issues
This fix resolves crashes reported by multiple developers using getCurrencyBalance() and potentially other method channel operations that experience timing issues.

This is a critical stability fix that prevents app crashes and should be prioritized for the next patch release.

This PR description clearly explains the problem, solution, and impact while emphasizing the critical nature of the fix for app stability.

@rdominic
Copy link

rdominic commented Jun 6, 2025

Thanks for you detailed feedback, we will review this for our next release. Good to hear you've managed to solve it for yourself for the now.

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.

2 participants