Skip to content
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

Not working when start Flutter Engine with FlutterFragment #241

Open
1 task
dochanhca opened this issue Mar 29, 2020 · 7 comments
Open
1 task

Not working when start Flutter Engine with FlutterFragment #241

dochanhca opened this issue Mar 29, 2020 · 7 comments
Labels
group: app-to-app Issues are all based around add-to-app feature of Flutter. P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. type: bug Something isn't working

Comments

@dochanhca
Copy link

🐛 Bug Report

Maybe method startListening() not being called when I start flutter engine with FlutterFragment. Because doesn't fired on onAttachedToActivity(@nonnull ActivityPluginBinding binding)?
So I getting this exception when trying to check permission: MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods).

Expected behavior

Reproduction steps

When I call :
final PermissionStatus statusFuture = await PermissionHandler()
.checkPermissionStatus(PermissionGroup.contacts);
I getting this error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods) #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7) <asynchronous suspension> #1 MethodChannelPermissionHandler.checkPermissionStatus (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:19:41) #2 PermissionHandler.checkPermissionStatus (package:permission_handler/permission_handler.dart:21:47) #3 InputCustomerInfoBloc._checkContactPermission (package:wallet_vietjet/src/blocs/input_customer_info_bloc.dart:384:10) #4 InputCustomerInfoBloc.requestOpenContact (package:wallet_vietjet/src/blocs/input_customer_info_bloc.dart:368:37) #5 _TextInputWidgetState._getRowChildren.<anonymous closure> (package:wallet_vietjet/src/ui/screens/input_customer_info_screen.dart:569:31) #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11) #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5) #9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7) #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27) #11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20) #12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22) #13 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7) #14 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7) #15 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7) #16 _rootRunUnary (dart:async/zone.dart:1138:13) #17 _CustomZone.runUnary (dart:async/zone.dart:1031:19) #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7) #19 _invoke1 (dart:ui/hooks.dart:273:10) #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)

Configuration

Platform:

  • 📱 iOS
  • [ x] 🤖 Android
@mvanbeusekom
Copy link
Member

Thank you for submitting this issue. Would you be able to supply a small example which reproduces this bug?

Also which version of the plugin are you using? We did implement support for Add-2-app features since 4.4.0.

@mvanbeusekom
Copy link
Member

I am asking for an example since I am not sure what you mean with “start FlutterEngine with FlutterFragment”

@dochanhca
Copy link
Author

dochanhca commented Mar 29, 2020

I'm using plugin ver 4.4.0+hotfix.2. I'm import my flutter project as a module inside Android native app.

Example code start FlutterEngine with FlutterFragment:

public class VietJetFlutterFragment extends FlutterFragment {
    
    @Override
    public FlutterEngine provideFlutterEngine(Context context) {
        FlutterEngine flutterEngine = new FlutterEngine(context);

        flutterEngine.getDartExecutor().executeDartEntrypoint(
                DartExecutor.DartEntrypoint.createDefault()
        );

        GeneratedPluginRegistrant.registerWith(flutterEngine);
       
        return flutterEngine;
    }

} 

I added FlutterFragment to an AppcompatActivity

flutterFragment = new VietJetFlutterFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.fr_vietjet, flutterFragment, flutterFragment.getClass().getSimpleName());
fragmentTransaction.commit();

Generated code from Flutter Engine:

@Keep
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
      flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.registerWith(shimPluginRegistry.registrarFor("flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.deviceinfo.DeviceInfoPlugin());
      io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin.registerWith(shimPluginRegistry.registrarFor("io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin"));
      io.scer.pdf.renderer.NativePDFRendererPlugin.registerWith(shimPluginRegistry.registrarFor("io.scer.pdf.renderer.NativePDFRendererPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
    flutterEngine.getPlugins().add(new com.baseflow.permissionhandler.PermissionHandlerPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
  }
}

@HuynhThien82
Copy link

I have same issue. I use flutter module as aar and import into android project as a fragment. Android 9 and earlier working fine. But android 10, sometimes it will ask permission, sometimes doesn't. I don't know why. Error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Android activity is required to check for permissions and cannot be null., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)

#2 MethodChannelPermissionHandler.checkPermissionStatus (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:15:41)
#3 PermissionActions.status (package:permission_handler/permission_handler.dart:25:51)

@akinsete
Copy link

akinsete commented Jan 20, 2021

Any suggestion on this issue? Currently having this issue with steps explained above.
@dochanhca were you bale to resolve this issue?

@syq7970
Copy link

syq7970 commented May 19, 2021

Same issue here, FlutterFragment class not trigged onAttachedToActivity, so I missed all plugin features.

@dupasj
Copy link

dupasj commented Aug 19, 2022

Do we have any update here ? :)
I figure out the problem. I copy/paste the exemple dart page into an empty flutter module project, when I run it, I have any errors around missing methods on message channel.
But once I embded it in a fragment, all the methods used by the plugins is not implemented.

@JeroenWeener JeroenWeener added platform: android Issue is related to the Android platform. type: bug Something isn't working P2 Important issues not at the top of the work list. labels Aug 17, 2023
@JeroenWeener JeroenWeener added the group: app-to-app Issues are all based around add-to-app feature of Flutter. label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group: app-to-app Issues are all based around add-to-app feature of Flutter. P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants