Debugging log · Runtime
ClassNotFoundException: "Didn't find class" at runtime
The app built without a single warning and then crashed the instant it launched: ClassNotFoundException: Didn't find class, naming a class I could see right there in my source. The contradiction is the clue — it compiled, so the class exists; it crashed looking for it, so the class wasn't on the device when the app ran. Those are two different moments, and something between them dropped the class.
The short version: the class was present at compile time but missing at runtime. The usual reasons: the app exceeded the single-dex limit without multidex, R8 stripped or renamed the class, or the manifest names a class that doesn't match. Match the cause to the symptom below.
The error
java.lang.ClassNotFoundException: Didn't find class "com.example.app.MainActivity" on path: DexPathList[...]
Note whether the named class is one of yours or from a library, and whether it's referenced from the manifest — those details point at different causes.
Cause 1 — multidex not enabled (older minSdk)
A single dex file can hold a limited number of methods. A large app on an older minSdk can exceed that and split into multiple dex files — but on API levels below 21, the device only loads the first one at startup, so classes in the others go missing at runtime. If your app is large and minSdk is low, enable multidex:
android {
defaultConfig { multiDexEnabled = true }
}
dependencies { implementation("androidx.multidex:multidex:2.0.1") }
This is the classic "crashes only on old devices" version — it runs fine on anything API 21+ and dies on older hardware.
Cause 2 — R8 stripped or renamed the class
In a release build, R8 removes code it believes is unused and renames the rest. A class only referenced by reflection or by name from the manifest can be deleted or renamed, so it's gone at runtime. If the crash happens in release but not debug, this is almost certainly it — add a keep rule for the class and build again. This is the same trap behind many release-only crashes.
Cause 3 — a wrong name in the manifest
If the missing class is one the manifest references — an activity, service, or custom Application — check the spelling and package. A renamed or moved class whose manifest entry wasn't updated, or a relative name (.MainActivity) that no longer matches the package, produces exactly this crash. The manifest string and the real class path have to agree.
Cause 4 — a stale or partial install
Occasionally the device is simply running an older APK, or an install went wrong. Uninstall the app from the device, clean the project, and reinstall:
adb uninstall com.example.app ./gradlew clean installDebug
This clears the case where your code is correct but the device never received the new class.
The fastest triage question: does it crash in debug too, or only in release? Only release → R8 (add a keep rule). Both, on old devices only → multidex. Both, everywhere, for a manifest-named class → a name mismatch. That one question usually names the cause.
Class and package names above are placeholders — use the exact name in your own crash.