-
Notifications
You must be signed in to change notification settings - Fork 254
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
No implementation found for method configure on channel com.amazonaws.amplify/core - on Android back button click #99
Comments
This issue does not happen when the app is backgrounded using the other Android bottom bar buttons. To reproduce, the Android back button must be pressed. The app is still backgrounded but the issue occurs afterwards. |
Looking at Flutter logs, one can see an inconsistency from Flutter in how the app is "backgrounded". If the app is backgrounded using the other Android bottom bar buttons the following lifecycle events occur: D/AutoSessionTracker( 8274): Activity paused: MainActivity In this case the app state is still preserved. |
However, when pressing the back button, the destroy lifecycle events occurs. At this point app state is lost and the crash will occur in the logs. Our Flutter app is now in an inconsistent state and probably not recoverable ... D/AutoSessionTracker( 8274): Activity paused: MainActivity I find it a bit strange why Flutter would destroy the MainActivity, yet still have the app "running" (ie. accessible as one of the backgrounded apps). |
This seems like an issue where the back button causes the FlutterActivity to be destroyed in Android instead of sending it to background. There are some workarounds mentioned here https://stackoverflow.com/questions/55539302/sending-your-application-to-background-when-back-button-is-pressed-in-flutter that can be used by the applications such as
We will discuss if it makes sense to provide such workarounds in the Amplify libraries or wait until Flutter provides a more standard solution. |
We discussed internally and it doesn't make sense for Amplify to provide a workaround in the library. As mentioned in the previous comment there are workarounds that can be done in the applications. |
In my experiment, this happens because cognito flutter registration fails (yes it can be called twice in this situation, see #312). Other plugins (I know for having dealing with this in my sqflite plugin) such as firebase handles this case gracefully. |
Reopening this as we did more deep dive into this and found out the root cause that is causing this issue. It is true that flutter's activity gets killed on the back button, however on resuming the application, flutter recreates the activity. This assumes that the platform plugin's initialization code is idempotent which is not the case with amplify-flutter since underlying libraries can only be configured (and adding plugins) only once, repeated calls return an exception. e.g. AnalyticsPlugin Flutter activity however swallows the exception (no error logs printed either) and fails to initialize the platform plugins resulting in the exception mentioned in this issue. The fix would be to make platform plugins' init code idempotent (catching and swallowing the specific exception about reconfiguration). Since the dart activity gets recreated again as well ( |
Console log shows:
E/flutter (31034): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method configure on channel com.amazonaws.amplify/core)
E/flutter (31034): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
E/flutter (31034):
E/flutter (31034): Initial Commit #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter (31034): feat(amplify_core): initial commit for amplify-flutter #2 MethodChannelAmplifyCore.configure (package:amplify_core_plugin_interface/method_channel_amplify.dart:25:21)
E/flutter (31034): feat(amplify_auth_cognito): initial commit for amplify_auth_cognito and amplify_auth_plugin_interface #3 Amplify.configure (package:amplify_core/amplify_core.dart:71:35)
E/flutter (31034): Amplify analytics #4 _MyAppState._initAmplifyFlutter (package:sample_app/main.dart:61:19)
E/flutter (31034): [RFC]: Amplify Flutter #5 _MyAppState.initState (package:sample_app/main.dart:52:5)
E/flutter (31034): feat(amplify_analytics): initial commit #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4684:58)
E/flutter (31034): Amplify analytics #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter (31034): Initial Commit - Sample App #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (31034): ci: add CircleCI config for running unit tests #9 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (31034): feat(amplify_auth_cognito): signIn, confirmSignIn, confirmSignUp and signOut #10 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1174:16)
E/flutter (31034): feat(amplify_auth_cognito): confirmSignUp, signIn, confirmSignIn, signOut #11 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1145:5)
E/flutter (31034): WIP: Readme #12 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:1087:17)
E/flutter (31034): feat(amplify_auth_cognito) password management and hub events #13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2620:19)
E/flutter (31034): feat(amplify_auth_cognito): password management and events #14 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1086:13)
E/flutter (31034): feat(amplify_storage_s3): UploadFile and GetUrl #15 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:927:7)
E/flutter (31034): feat(ampify_auth_cognito): credentials #16 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:908:7)
E/flutter (31034): Android unit tests analytics #17 _rootRun (dart:async/zone.dart:1182:47)
Originally posted by @kjones in #80 (comment)
The text was updated successfully, but these errors were encountered: