flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.82k stars 3.23k forks source link

Add mention of updating Activity name in manifest when setting up a MethodChannel in 'Writing custom platform-specific code' page #8450

Open navaronbracke opened 1 year ago

navaronbracke commented 1 year ago

Page URL

https://docs.flutter.dev/development/platform-integration/platform-channels?tab=type-mappings-kotlin-tab#step-3-add-an-android-platform-specific-implementation

Page source

No response

Describe the problem

The Android section for setting up a MethodChannel or EventChannel lacks an important step: Updating the name of the Activity in the manifest.

When a new Flutter project is first created, you get an empty Activity that merely extends FlutterActivity. This works, until you start adding native code to that Activity.

Once you modified the Activity to setup up some native code, you'll have to update the Activity name in the Manifest.xml from

android:name="io.flutter.embedding.android.FlutterActivity"

to (assuming the default name is kept)

android:name=".MainActivity"

Expected fix

Add a section that indicates that the Manifest.xml should be updated.

Additional context

Without this addition to the Manifest.xml, people will be getting MissingPluginExceptions when using the channels, despite following the tutorial.

mossmana commented 1 year ago

This is on my backlog of things to look into. However, given my other priorities, I may not get to it for a while. If this issue needs to be completed sooner, someone else may need to take this work on.