{
  "id": "android/multidex-main-dex-list-error",
  "signature": "Error: Cannot fit requested classes in a single dex file. Try supplying a main-dex-list.",
  "signature_zh": "错误：无法将请求的类放入单个 dex 文件中。请尝试提供 main-dex-list。",
  "regex": "Cannot fit requested classes in a single dex file\\. Try supplying a main-dex-list",
  "domain": "android",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "The number of methods in the app exceeds the 64K limit per dex file, and the build system cannot determine which classes must go into the primary dex.",
  "root_cause_type": "generic",
  "root_cause_zh": "应用中的方法数超过了每个 dex 文件的 64K 限制，且构建系统无法确定哪些类必须进入主 dex。",
  "versions": [
    {
      "version": "Android 5.0 (API 21)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 6.0 (API 23)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android Gradle Plugin 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android Gradle Plugin 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "For apps with very large method counts, automatic resolution may fail if certain classes must be in the primary dex for startup.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This is an extreme measure that breaks functionality; the real fix is proper multidex configuration.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Create a main-dex-list.txt file in the app's root directory listing classes that must be in the primary dex (e.g., Application subclass, Activity, Service). Then configure build.gradle: 'multiDexKeepProguard file('main-dex-list.txt')'.",
      "success_rate": 0.9,
      "how": "Create a main-dex-list.txt file in the app's root directory listing classes that must be in the primary dex (e.g., Application subclass, Activity, Service). Then configure build.gradle: 'multiDexKeepProguard file('main-dex-list.txt')'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable multidex in build.gradle: 'defaultConfig.multiDexEnabled true' and add the multidex dependency: 'implementation 'androidx.multidex:multidex:2.0.1''. For apps targeting API < 21, ensure the Application class extends MultiDexApplication.",
      "success_rate": 0.85,
      "how": "Enable multidex in build.gradle: 'defaultConfig.multiDexEnabled true' and add the multidex dependency: 'implementation 'androidx.multidex:multidex:2.0.1''. For apps targeting API < 21, ensure the Application class extends MultiDexApplication.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use ProGuard or R8 to shrink the code and remove unused methods, reducing the overall method count below the 64K limit.",
      "success_rate": 0.8,
      "how": "Use ProGuard or R8 to shrink the code and remove unused methods, reducing the overall method count below the 64K limit.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在应用根目录创建 main-dex-list.txt 文件，列出必须放入主 dex 的类（例如 Application 子类、Activity、Service）。然后在 build.gradle 中配置：'multiDexKeepProguard file('main-dex-list.txt')'。",
    "在 build.gradle 中启用 multidex：'defaultConfig.multiDexEnabled true' 并添加 multidex 依赖：'implementation 'androidx.multidex:multidex:2.0.1''。对于目标 API < 21 的应用，确保 Application 类继承 MultiDexApplication。",
    "使用 ProGuard 或 R8 进行代码压缩，移除未使用的代码，将总方法数减少到 64K 限制以下。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/studio/build/multidex",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-04-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}