{
  "id": "android/activity-recreated-savedinstancestate-null",
  "signature": "java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.getSerializable(java.lang.String)' on a null object reference",
  "signature_zh": "java.lang.RuntimeException：无法启动活动 ComponentInfo{com.example/com.example.MainActivity}：java.lang.NullPointerException：尝试对 null 对象引用调用虚拟方法 'java.lang.Object android.os.Bundle.getSerializable(java.lang.String)'",
  "regex": "RuntimeException.*Unable to start activity.*NullPointerException.*getSerializable.*on a null object reference",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Activity is recreated (e.g., after rotation or process death) and `savedInstanceState` is null, but the code attempts to retrieve a serializable object from the bundle without null check.",
  "root_cause_type": "generic",
  "root_cause_zh": "活动被重新创建（例如，旋转或进程终止后），`savedInstanceState` 为 null，但代码尝试从 bundle 中检索可序列化对象而没有进行空检查。",
  "versions": [
    {
      "version": "Android 11 (API 30)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 14 (API 34)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "AndroidX Activity 1.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only prevents recreation due to orientation changes, not process death or other configuration changes (e.g., locale). The NPE still occurs in other scenarios.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Calling super.onCreate() is already standard practice; the NPE occurs because `savedInstanceState` itself is null, not because it's accessed before super call.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add a null check before accessing the bundle: `if (savedInstanceState != null) { val data = savedInstanceState.getSerializable(\"key\") }`",
      "success_rate": 0.95,
      "how": "Add a null check before accessing the bundle: `if (savedInstanceState != null) { val data = savedInstanceState.getSerializable(\"key\") }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `onSaveInstanceState` to persist data and `onRestoreInstanceState` to restore it safely with null checks: `override fun onRestoreInstanceState(savedInstanceState: Bundle) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey(\"key\")) { val data = savedInstanceState.getSerializable(\"key\") } }`",
      "success_rate": 0.9,
      "how": "Use `onSaveInstanceState` to persist data and `onRestoreInstanceState` to restore it safely with null checks: `override fun onRestoreInstanceState(savedInstanceState: Bundle) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey(\"key\")) { val data = savedInstanceState.getSerializable(\"key\") } }`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add a null check before accessing the bundle: `if (savedInstanceState != null) { val data = savedInstanceState.getSerializable(\"key\") }`",
    "Use `onSaveInstanceState` to persist data and `onRestoreInstanceState` to restore it safely with null checks: `override fun onRestoreInstanceState(savedInstanceState: Bundle) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey(\"key\")) { val data = savedInstanceState.getSerializable(\"key\") } }`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/guide/components/activities/activity-lifecycle#saving-state",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-12-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}