{
  "id": "android/multidex-keep-cannot-find-class",
  "signature": "java.lang.RuntimeException: Unable to instantiate application com.example.MyApp: java.lang.ClassNotFoundException: Didn't find class \"com.example.MyApp\" on path: DexPathList[[zip file \"/data/app/...\"],nativeLibraryDirectories=[/data/app/...]]",
  "signature_zh": "java.lang.RuntimeException: 无法实例化应用程序 com.example.MyApp: java.lang.ClassNotFoundException: 在路径上未找到类 \"com.example.MyApp\"",
  "regex": "java\\.lang\\.RuntimeException: Unable to instantiate application .*: java\\.lang\\.ClassNotFoundException: Didn't find class \".*\" on path: DexPathList",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "MultiDex application class not loaded because the main dex file does not include the custom Application class; MultiDex.install() may not be called early enough or using legacy multidex without proper keep configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于主 dex 文件未包含自定义 Application 类，MultiDex 应用程序类未加载；可能未在足够早的阶段调用 MultiDex.install()，或使用了旧版 multidex 但未正确配置 keep。",
  "versions": [
    {
      "version": "Android 4.4 - 14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android Gradle Plugin 3.6 - 8.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "multidex:1.0.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The Application class must be explicitly kept in the main dex; simply adding other classes does not solve the instantiation failure.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If the app still targets lower API levels or uses legacy multidex, the error persists; also, this may not be feasible for apps supporting older devices.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The root cause is a missing class in the main dex, which cannot be fixed by a simple rebuild; the multidex keep configuration is still incorrect.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add the custom Application class to the main dex keep list by creating a file 'multidex.keep' in the app directory with content: 'com/example/MyApp.class', then in build.gradle: 'multiDexKeepFile file('multidex.keep')'.",
      "success_rate": 0.85,
      "how": "Add the custom Application class to the main dex keep list by creating a file 'multidex.keep' in the app directory with content: 'com/example/MyApp.class', then in build.gradle: 'multiDexKeepFile file('multidex.keep')'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Override attachBaseContext() in the Application class to call MultiDex.install() before super.attachBaseContext(): 'public class MyApp extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }'",
      "success_rate": 0.9,
      "how": "Override attachBaseContext() in the Application class to call MultiDex.install() before super.attachBaseContext(): 'public class MyApp extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'androidx.multidex:multidex:2.0.1' and enable multidex in build.gradle: 'defaultConfig { multiDexEnabled true }' and set minSdkVersion to 21 if possible.",
      "success_rate": 0.95,
      "how": "Use 'androidx.multidex:multidex:2.0.1' and enable multidex in build.gradle: 'defaultConfig { multiDexEnabled true }' and set minSdkVersion to 21 if possible.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add the custom Application class to the main dex keep list by creating a file 'multidex.keep' in the app directory with content: 'com/example/MyApp.class', then in build.gradle: 'multiDexKeepFile file('multidex.keep')'.",
    "Override attachBaseContext() in the Application class to call MultiDex.install() before super.attachBaseContext(): 'public class MyApp extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }'",
    "Use 'androidx.multidex:multidex:2.0.1' and enable multidex in build.gradle: 'defaultConfig { multiDexEnabled true }' and set minSdkVersion to 21 if possible."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/build/multidex",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}