Skip to content

Manual steps required when plugin depends on FlutterFragmentActivity #10690

@tvolkert

Description

@tvolkert

Some plugins (right now, google_sign_in) require that your main app activity be an instance of android.support.v4.app.FragmentActivity. Right now, Flutter makes this possible, but not as easy as it could be. The current state is:

  1. Flutter provides io.flutter.app.FlutterFragmentActivity out of the box, but it doesn't bundle the android-support-v4 library, upon which that activity depends at runtime (it omits this library on purpose to avoid bloating application binaries that don't need to use FlutterFragmentActivity).
  2. The plugin's Gradle dependency pulls in the requisite android-support-v4 library so that the necessary classes are available at runtime.
  3. The plugin throws a runtime exception if it detects that your app's activity isn't an instance of FragmentActivity. The exception message directs the user towards FlutterFragmentActivity.
  4. The developer has to manually edit their MainActivity to extend from FlutterFragmentActivity rather than from FlutterActivity in order to get back up and running.

While the good news is that we support the use case of plugins that require FragmentActivity, the developer experience leaves something to be desired. Notably, the developer under normal circumstances doesn't need to hand edit anything in MainActivity - the auto-plugin-registration takes care of any would-be edits. So telling them to go hand-edit the activity is a break from the developer experience they've come to expect.

Metadata

Metadata

Labels

p: toolingAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions