1
我在我的Android手机应用程序中仅使用三星和QMobile的特定设备获取了几个NoClassDefFoundError。如何检查NoClassDefFoundError?
将添加下面的代码检测错误?
//Check for Class not found error for Samsung 4.2.2 devices case
try {
Class.forName("android.support.v7.internal.view.menu.MenuBuilder");
} catch (ClassNotFoundException e) {
// Handle Exception by displaying an alert to user to update device firmware.
}catch (NoClassDefFoundError e){
// Handle Exception by displaying an alert to user to update device firmware.
}
什么是主动检测的NoClassDefFoundError没有在应用程序崩溃结束了最好的方法是什么?
编辑:
的documentation说,该方法将抛出以下异常,并没有提到关于NoClassDefFoundError
什么。
Throws:
LinkageError - if the linkage fails
ExceptionInInitializerError - if the initialization provoked by this method fails
ClassNotFoundException - if the class cannot be located
我可以改写像
威尔
Class.forName(String)
扔NoClassDefFoundError
或如何检查如果一个类有一个“防守”的问题?
你正在处理它的catch块,它不应该崩溃 –
@SoumitriPattnaik我不包围问题导致语句与try/catch块。我只是试图主动触发异常,并检查应用程序是否继续运行,是否会崩溃。 – brainless
如果它是在一个特定的方法,为什么不'抛出NoClassDefFoundError'并在调用方法中处理它。 我只是说,可能有更好的解决方案。 –