{
  "id": "flutter/method-channel-timeout",
  "signature": "MissingPluginException: Timeout waiting for method call result on channel com.example.app/channel",
  "signature_zh": "MissingPluginException: 在通道 com.example.app/channel 上等待方法调用结果超时",
  "regex": "MissingPluginException: Timeout waiting for method call result on channel .+",
  "domain": "flutter",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Platform channel method call from Dart to native side timed out because the native handler never called result.success or result.error, often due to a missing plugin registration or a blocking main thread operation.",
  "root_cause_type": "generic",
  "root_cause_zh": "从 Dart 到原生端的平台通道方法调用超时，因为原生处理程序从未调用 result.success 或 result.error，通常是由于缺少插件注册或主线程操作阻塞。",
  "versions": [
    {
      "version": "Flutter 3.16.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Flutter 3.22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Dart 3.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase the default timeout duration in Dart code",
      "why_fails": "The timeout is not the root cause; the native side never responds, so extending the timeout only delays the failure.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restart the Flutter app without cleaning the build cache",
      "why_fails": "If the plugin is not registered, restarting without cleaning retains the stale state; a clean build is required.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrap the method call in a try-catch and ignore the exception",
      "why_fails": "Ignoring the exception suppresses the error but leaves the underlying issue unresolved, leading to silent failures in other features.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the native plugin is registered. In Android, check that the plugin class is added in MainActivity.kt/Java under configureFlutterEngine. For example, in MainActivity.kt:\n  override fun configureFlutterEngine(flutterEngine: FlutterEngine) {\n    super.configureFlutterEngine(flutterEngine)\n    flutterEngine.plugins.add(MyPlugin())\n  }",
      "success_rate": 0.8,
      "how": "Ensure the native plugin is registered. In Android, check that the plugin class is added in MainActivity.kt/Java under configureFlutterEngine. For example, in MainActivity.kt:\n  override fun configureFlutterEngine(flutterEngine: FlutterEngine) {\n    super.configureFlutterEngine(flutterEngine)\n    flutterEngine.plugins.add(MyPlugin())\n  }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify that the native handler always calls result.success or result.error. In Android, wrap the method call implementation in a try-finally block to ensure result is invoked. Example:\n  override fun onMethodCall(call: MethodCall, result: Result) {\n    try {\n      if (call.method == \"getData\") {\n        result.success(fetchData())\n      }\n    } catch (e: Exception) {\n      result.error(\"ERROR\", e.message, null)\n    }\n  }",
      "success_rate": 0.85,
      "how": "Verify that the native handler always calls result.success or result.error. In Android, wrap the method call implementation in a try-finally block to ensure result is invoked. Example:\n  override fun onMethodCall(call: MethodCall, result: Result) {\n    try {\n      if (call.method == \"getData\") {\n        result.success(fetchData())\n      }\n    } catch (e: Exception) {\n      result.error(\"ERROR\", e.message, null)\n    }\n  }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Run 'flutter clean' and 'flutter pub get' to re-register all plugins, then rebuild the app.",
      "success_rate": 0.75,
      "how": "Run 'flutter clean' and 'flutter pub get' to re-register all plugins, then rebuild the app.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保原生插件已注册。在 Android 中，检查 MainActivity.kt/Java 的 configureFlutterEngine 中添加了插件类。例如，在 MainActivity.kt 中：\n  override fun configureFlutterEngine(flutterEngine: FlutterEngine) {\n    super.configureFlutterEngine(flutterEngine)\n    flutterEngine.plugins.add(MyPlugin())\n  }",
    "验证原生处理程序始终调用 result.success 或 result.error。在 Android 中，使用 try-finally 块包装方法调用实现以确保调用 result。示例：\n  override fun onMethodCall(call: MethodCall, result: Result) {\n    try {\n      if (call.method == \"getData\") {\n        result.success(fetchData())\n      }\n    } catch (e: Exception) {\n      result.error(\"ERROR\", e.message, null)\n    }\n  }",
    "运行 'flutter clean' 和 'flutter pub get' 重新注册所有插件，然后重新构建应用。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.flutter.dev/platform-integration/platform-channels",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2024-02-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}