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

Sometimes Android will crash. #3

Open
95DBC opened this issue Sep 11, 2020 · 3 comments
Open

Sometimes Android will crash. #3

95DBC opened this issue Sep 11, 2020 · 3 comments

Comments

@95DBC
Copy link

95DBC commented Sep 11, 2020

Hello, I have encountered this problem now, how can I solve it?

AsyncTask #6(32962)

java.lang.RuntimeException

Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #6

1 io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(Unknown Source:36)

2 io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(Unknown Source:0)
3 io.flutter.embedding.engine.dart.DartMessenger.send(Unknown Source:60)
4 io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(Unknown Source:3)
5 io.flutter.embedding.engine.dart.DartExecutor.send(Unknown Source:2)
6 io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler$EventSinkImplementation.success(Unknown Source:49)
7 k.b.a.a.a(Unknown Source:6)
8 k.b.a.a.b(Unknown Source:0)
9 k.b.a.a$a.a(Unknown Source:22)
10 com.facebook.applinks.a.c(Unknown Source:212)
11 com.facebook.applinks.a.a(Unknown Source:0)
12 com.facebook.applinks.a$a.run(Unknown Source:6)
13 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
14 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
15 java.lang.Thread.run(Thread.java:919)

微信图片_20200911105402

@orestesgaolin
Copy link

Potential solution for that in FacebookDeeplinksPlugin.java:

  private void initFacebookAppLink() {
    Intent intent = getIntent();
    final Activity act = this.activityPluginBinding.getActivity();
    if (intent != null && intent.getAction() == Intent.ACTION_VIEW) {
      initialUrl = intent.getDataString();
      handleLink(initialUrl);
    }

    FacebookSdk.setAutoInitEnabled(true);
    FacebookSdk.fullyInitialize();
    AppLinkData.fetchDeferredAppLinkData(context, 
      new AppLinkData.CompletionHandler() {
        @Override
        public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
          if (appLinkData == null) {
            return;
          }
          initialUrl = appLinkData.getTargetUri().toString();
          act.runOnUiThread(() -> { // need to run on main thread
            handleLink(initialUrl);
          });
        }
      }
    );
  }

@95DBC
Copy link
Author

95DBC commented Dec 17, 2020

Thank you very much, it really works.

@95DBC
Copy link
Author

95DBC commented Dec 17, 2020

Potential solution for that in FacebookDeeplinksPlugin.java:

  private void initFacebookAppLink() {
    Intent intent = getIntent();
    final Activity act = this.activityPluginBinding.getActivity();
    if (intent != null && intent.getAction() == Intent.ACTION_VIEW) {
      initialUrl = intent.getDataString();
      handleLink(initialUrl);
    }

    FacebookSdk.setAutoInitEnabled(true);
    FacebookSdk.fullyInitialize();
    AppLinkData.fetchDeferredAppLinkData(context, 
      new AppLinkData.CompletionHandler() {
        @Override
        public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
          if (appLinkData == null) {
            return;
          }
          initialUrl = appLinkData.getTargetUri().toString();
          act.runOnUiThread(() -> { // need to run on main thread
            handleLink(initialUrl);
          });
        }
      }
    );
  }

Thank you very much, it really works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants