devmuaz
devmuaz

Reputation: 629

flutter method channel always throws MissingPluginException [Android]

I have this platform-specific code which uses the MethodChannel, and it always throws a MissingPluginException, although the implementation is already exists in Android main activity file!

MainActivity.kt file (Android): enter image description here

engage_service.dart file (Flutter): enter image description here

error: enter image description here

Anyone can help identifying the problem here? it would really mean a lot!!

Upvotes: 0

Views: 2107

Answers (2)

Lesego Mabe
Lesego Mabe

Reputation: 1

Also, in your invokeMethodCall, you have to include your channel name as a prefix to the name of the function you're invoking i.e. "_invokeMethodCall("$_channelName/register", args...)" otherwise it won't recognise which method belonging to which channel you're trying to call.

Upvotes: 0

devmuaz
devmuaz

Reputation: 629

I solved it with the help of this incredible guy @Ryosuke,

What I was doing is using this activity com.ryanheise.audioservice.AudioServiceActivity which belongs to this package just_audio_background as the main activity in the AndroidManifest.xml instead of the MainActivity.

So I replaced it with the MainActivity and then in the MainActivity I changed its extension which was FlutterActivity with AudioServiceActivity since this class itself extends the FlutterActivity.

Thank You @Ryosuke

Upvotes: 1

Related Questions