Some of users of my application got this exception
java.lang.NoClassDefFoundError: [generic]
at dalvik.system.NativeStart.main(Native Method)
It's not common exception because of great number of users and only some of them have this exception. I don't use any native library and all externals libraries don't use any native code
Version of Android where it happened:
Can anybody help me with workaround? Can receiver in AndroidManifest call this issue?
NoClassDefFoundError
with the [generic]
tag is thrown by the VM, from a "pre-fabricated" object. The exception has no useful stack trace, but does not generally appear by itself.
Background: the class loader mechanism requires throwing exceptions when a class can't be found in a loader. Loaders have to defer to their parent loader, so if you try to load an application class, it will first ask the bootstrap loader, which will fail and throw an exception. The app loader then does its own lookup, which will probably succeed.
This means the VM is allocating an exception, initializing the object, and filling in the stack trace... and then throwing it away, for every class that isn't coming out of the bootstrap class loader.
To avoid pointless allocations, the bootstrap loader (implemented inside the VM) throws a generic pre-allocated exception object. Because the object is fully formed when the VM is starting up, it has no meaningful stack trace information.
In practice you don't see these, because applications don't generally load classes directly from the bootstrap loader. The application or system loader creates a meaningful exception for you. Even if you request a class from the bootstrap loader directly, you should only see this as the "cause" of a ClassNotFoundException
.
The DexClassLoader
was written to use an error code instead of an exception when a class can't be found, so you won't see this at all through that path.
If the NoClassDefFoundError
is the "cause" of a larger exception, you need to get the outermost exception, as that will have the meaningful stack trace. If you're seeing these appear by themselves, then something very strange is doing on -- most likely some bit of code is attempting to load classes directly and is passing null
instead of a classloader object (which is how you reference the bootstrap loader).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With