Android: When do classes get unloaded by the system?

前端 未结 2 409
小蘑菇
小蘑菇 2020-12-11 17:18

This is a very weird problem. My app that runs just fine but somehow if I leave my phone for an hour or two while my app is running, I get the following error when I come ba

2条回答
  •  离开以前
    2020-12-11 18:21

    The Dalvik VM doesn't currently unload classes. If it did, it would only be able to do so when all classes associated with a particular class loader could be unloaded at once, which will not be the case while your app is running.

    You need to check the logcat output for errors leading up to this exception. One way to get a NoClassDefFoundError is for something to fail during initialization of the class in question; if that happened there would likely be a trail in the log.

    (Of course, by now the logcat output is probably long gone, but if the problem is repeatable you'll want to capture it next time.)

提交回复
热议问题