e.printStackTrace()工作正常(即将我的堆栈跟踪打印到stderr),但是Log.X根本无法打印堆栈跟踪.
例如:
} catch (IOException e) { Log.e("Network","Exception",e); e.printStackTrace(); }
输出:
08-31 03:46:21.992: W/Network(13238): Exception 08-31 03:46:22.092: W/System.err(13238): java.net.UnknownHostException: Unable to resolve host "...": No address associated with hostname 08-31 03:46:22.204: W/System.err(13238): at java.net.InetAddress.lookupHostByName(InetAddress.java:394) 08-31 03:46:22.222: W/System.err(13238): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 08-31 03:46:22.222: W/System.err(13238): at java.net.InetAddress.getAllByName(InetAddress.java:214)
解决方法
结果是Android的Log.getStackTraceString被Log.X使用的是UnknownHostException. 原文链接:https://www.f2er.com/android/312223.html