• Android平台下奔溃Crash和无响应ANR日志抓取分析


    一、使用AndroidStudio

    在logcat中查看实时日志,需要选择连接的手机和应用包名

    AS下载链接

    二、使用adb shell dumpsys dropbox命令获取

    1. #!/bin/bash
    2. # path="/data/system/dropbox" # 在手机这个目录下存储了崩溃日志
    3. newest_time=$(adb shell dumpsys dropbox | grep 'data_app_crash' | awk 'END {print $1,$2}')
    4. adb shell dumpsys dropbox --print ${newest_time}
    5. # echo -e "时间是:${newest_time}"

    三、使用adb+logcat获取

    1. # 清除日志,日志内容很多,对于能毕现的日志,可以先清除后重新获取
    2. adb logcat -c
    3. # 然后再次运行崩溃操作,再抓取日志
    4. # 存储日志到当前目录下的 carsh.log 中
    5. adb logcat -d *:W > crash.log
    6. # W指的是警告以上日志
    7. # 这个日志文件包含了所有打印的日志,需要自己筛选下崩溃日志,比如搜索 begin、crash、Exception
    8. # 为了更精确的筛选日志,可以加入筛选条件
    9. adb logcat -d *:W grep "包名" >E:\crashlog2.txt

    四、获取无响应ANR的日志

    1. # 在/data/anr/目录下存储所有了ANR日志(Application Not Responding)
    2. adb pull /data/anr/ ~/Downloads

    五、常见的异常汇总

    1. NullPointerException:指针为空异常
    2. java.lang.NullPointerException: Attempt to invoke virtual method ‘…’ on a null object reference
    3. ClassCastException:类型转换异常
    4. java.lang.ClassCastException: … cannot be cast to
    5. IllegalArgumentException:非法参数异常
    6. java.lang.IllegalArgumentException: … is not a valid argument
    7. IllegalStateException:非法状态异常
    8. java.lang.IllegalStateException: … is not in a valid state
    9. IndexOutOfBoundsException:越界异常
    10. java.lang.IndexOutOfBoundsException: Index … out of bounds for length
    11. OutOfMemoryError:内存溢出错误
    12. java.lang.OutOfMemoryError: Failed to allocate a … byte allocation withfree bytes and …MB until OOM, target footprint …MB, growth limit …MB
    13. NoSuchMethodError:方法不存在错误
    14. java.lang.NoSuchMethodError: … method not found
    15. ArithmeticException:算术异常
    16. java.lang.ArithmeticException: … / by zero
    17. SecurityException:安全异常
    18. java.lang.SecurityException: … not allowed to perform operation
    19. NetworkOnMainThreadException:主线程网络异常
    20. android.os.NetworkOnMainThreadException
    21. InflateException:布局解析异常
    22. android.view.InflateException: Binary XML file line #…: Error inflating class
    23. ResourcesNotFoundException:资源未找到异常
    24. android.content.res.Resources$NotFoundException: Resource ID #… not found
    25. SQLiteDatabaseLockedException:SQLite数据库锁定异常
    26. android.database.sqlite.SQLiteDatabaseLockedException: database is locked
    27. SQLiteException:SQLite数据库异常
    28. android.database.sqlite.SQLiteException: … error code
    29. StaleDataException:数据过期异常
    30. android.database.StaleDataException: Attempted to access a cursor after it has been closed.
    31. VerificationError:验证错误
    32. java.lang.VerifyError: … accessfrom incompatible class
    33. AssertionError:断言错误
    34. java.lang.AssertionError: … assertion failed
    35. NoSuchAlgorithmException:加密算法不存在异常
    36. java.security.NoSuchAlgorithmException: … algorithm not available
    37. SocketException:Socket异常
    38. java.net.SocketException: … failed: ECONNREFUSED (Connection refused)
    39. SSLException:SSL异常
    40. javax.net.ssl.SSLException: … SSL handshake aborted
    41. FileNotFoundException:文件未找到异常
    42. java.io.FileNotFoundException: … (No such file or directory)
    43. IOException:IO异常
    44. java.io.IOException: … (Connection timed out)
    45. ParseException:解析异常
    46. java.text.ParseException: Unparseable date: “…”
    47. JSONException:JSON解析异常
    48. org.json.JSONException: … at character
    49. SAXException:SAX解析异常
    50. org.xml.sax.SAXException: … at line
    51. NumberFormatException:数字格式化异常
    52. java.lang.NumberFormatException: For input string: “…”
    53. IllegalStateException:线程状态异常
    54. java.lang.IllegalStateException: Cannot execute task: the task is already running.
    55. ConcurrentModificationException:并发修改异常
    56. java.util.ConcurrentModificationException: … (java.util.ConcurrentModificationException)
    57. UnsupportedOperationException:不支持的操作异常
    58. java.lang.UnsupportedOperationException: … not supported
    59. InterruptedException:线程中断异常
    60. java.lang.InterruptedException: sleep interrupted
    61. RuntimePermission:权限异常
    62. java.lang.RuntimePermission: … permission required
    63. AuthenticationException:认证异常
    64. org.apache.http.client.ClientProtocolException: … (authentication challenge)
    65. FileNotFoundException:未找到文件异常
    66. java.io.FileNotFoundException: … File not found.
    67. UnsupportedOperationException:不支持的操作异常
    68. java.lang.UnsupportedOperationException: … not supported
    69. EOFException:文件结尾异常
    70. java.io.EOFException: … end of file reached
    71. ConnectException:连接异常
    72. java.net.ConnectException: … Connection refused
    73. SocketTimeoutException:Socket超时异常
    74. java.net.SocketTimeoutException: … Read timed out
    75. JNIException:Java本机接口异常
    76. java.lang.reflect.InvocationTargetException: JNI Exception: …
    77. NoSuchProviderException:提供程序不存在异常
    78. java.security.NoSuchProviderException: Provider … not found
    79. Surface.OutOfResourcesException:Surface资源耗尽异常
    80. android.view.Surface$OutOfResourcesException: … (Surface with no valid EGLContext)
    81. WindowManager.BadTokenException:无效的Window Token异常
    82. android.view.WindowManager$BadTokenException: … is not valid; is your activity running?
    83. TimeoutException:超时异常
    84. java.util.concurrent.TimeoutException: … timeout
    85. SSLHandshakeException:SSL握手异常
    86. javax.net.ssl.SSLHandshakeException: … SSL handshake aborted
    87. SAXParseException:SAX解析异常
    88. org.xml.sax.SAXParseException: … at line
    89. IllegalStateException:未知的Bundle标记异常
    90. java.lang.IllegalStateException: Unknown Bundle Marker at position …: …
    91. IllegalArgumentException:传递了错误的方位坐标
    92. java.lang.IllegalArgumentException: Point (?, ?) must be in the range ? <= x <= ? and ? <= y <= ?
    93. SQLiteReadOnlyDatabaseException:SQLite只读数据库异常
    94. android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write to a readonly database
    95. SQLException:SQL异常
    96. java.sql.SQLException: … SQL exception
    97. ZipException:压缩文件异常
    98. java.util.zip.ZipException: … Not in GZIP format
    99. DifferentKeyException:与此密钥不相关的密钥异常
    100. java.security.spec.InvalidKeySpecException: Inappropriate key specification: Different key pair generated for given keyUsageInfo

    六、参考链接

    50个Android开发中常见的异常崩溃情况

    Android崩溃日志获取方式

  • 相关阅读:
    已解决java.security.acl.AclNotFoundException异常的正确解决方法,亲测有效!!!
    jenkins安装和配置(一):ubuntu 20.04 jenkins安装
    js 取整,保留2位小数
    【SpringMVC】处理器的封装和请求寻找到对应处理器的过程
    使用STM32控制TMC5160驱动步进电机
    “带薪划水”偷刷阿里老哥的面经宝典,三次挑战字节,终成正果
    Django 官网项目 四
    svn服务器迁移包括日志
    Vue 3中的reactive:响应式状态的全面管理
    以JSP为视图解析器搭建SSM项目
  • 原文地址:https://blog.csdn.net/jlhx123456/article/details/132982722