Unity 之 安卓堆栈跟踪和日志工具 (Android Logcat | 符号表解析Bugly捕获)

Posted 陈言必行

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity 之 安卓堆栈跟踪和日志工具 (Android Logcat | 符号表解析Bugly捕获)相关的知识,希望对你有一定的参考价值。

Unity 之 日志解析工具 android Logcat

一,工具集成

Logcat是开发者必备的工具,调试app时的闪退,异常,等问题都可以在这里看到。

Android Logcat包是在Unity Editor中显示来自Android设备的堆栈跟踪和日志等消息。


1.1 注意事项

Android Logcat软件包需要Unity 2019.4或更高版本以及Android支持模块。需要添加Android模块:

导入前需要注意:确保你的工程已加载Android模块,并且可以切到Android平台。

确认后在“build Settings”窗口中切换到Android构建目标。


1.2 导入插件

在Package Manager(Window” --> PackageManager)界面中导入:

插件简介:

Android Logcat软件包支持:

  • Android:日志消息

  • Android:应用程序内存统计

  • Android:屏幕捕获

  • Android:屏幕记录器

  • Stacktrace:实用程序

可以通过“Window > Analysis > Android Logcat ”在Unity Editor中访问该窗口。

窗口打开快捷键:Windows 按“Alt+6”;macOS “Option+6”


二,连接设备

Android Logcat软件包支持USB和无线连接。本节介绍如何将Android设备连接到Android Logcat窗口。

2.1 使用USB连接

当您打开Android Logcat窗口时,Unity会自动将任何USB连接的Android设备添加到设备列表中。

手机连接上USB之后,需要选择:传输文件。若没有此选项,则需要打开开发者模式。

PS: 在手机版本上多次点击才可以唤醒出开发者模式,再次点击则有吐司提示您已处于开发者模式,这时再去更多设置中去找开发者模式并开启即可。

检测上之后,即可在窗口中看到实时日志了:


2.2 无线连接

要将Android设备连接到Android Logcat窗口:

无线连接,还是得先使用2.1方式使用USB链接一下,然后打开Android Logcat窗口,从工具栏中,选择“设备选择器”。

选择其他连接选项:

在打开的窗口中,找到对应设备点击Connect:

连接成功提示:(不使用USB方式链接,直接输入IP地址,总是链接失败,不知道为什么[\\疑惑])

连接成功后,拔掉USB连接,就可以在可用设备窗口,找到Wifi链接的了:

PS:一次只能连接到一个设备。要选择要连接的设备,请使用Android Logcat窗口中的设备列表。此列表包含已连接设备的设备ID。

可以看到实时日志了:

若需要断开连接,可以在连接窗口对应设备后点击“Disconnect”:

再次连接,直接点最下面的Connect链接,即可链接成功。


三,实用功能介绍

3.1 通用介绍

  1. 筛选包名查看日志
    点击No Filter,在弹出的下拉菜单中,即可选择当前运行应用的包名,进行查看当前应用的相关日志:

  2. 筛选日志信息
    Logcat工具支持在搜索框输入正则表达式检索和区分大小写功能:

  3. Reconnect重新连接,Disconnect断开链接
    当我们出现一个问题,需要查看日志时,为了防止日志太多将需要查看的日志刷过去,则可以点击Disconnect断开链接,停止捕获更新日志信息。需要再次查看日志时,点击Reconnect重新连接。


3.2 堆栈跟踪工具 – 解析Bugly捕获报错

Tools下拉菜单下选择Stacktrace Utility 可以打开工具面板:

准备工作:指定符号表)

Project Setting面板 -> Analysis -> Android Logcat Settings 中设置:

PS:打包时用的哪个就导入哪个,看你打包时的工程设置:Player -> Configuration

若不指定会在解析时报错提示:

At least one symbol path needs to be specified.
Click Configure Symbol Paths and add the necessary symbol path.

举个例子:解析Bugly捕获报错

操作步骤:复制Bugly报错到工具Original界面,然后点击Resolve Stacktraces 即可:

解析前日志:

at libunity.0x577cd8(Native Method)
at libunity.0x583bdc(Native Method)
at libunity.0x5844b8(Native Method)
at libunity.0x583870(Native Method)
at libunity.0x58380c(Native Method)
at libunity.0x1d9058(Native Method)
at libil2cpp.0x2bd4b20(Native Method)
at libil2cpp.0x2bd6008(Native Method)
at libil2cpp.0x278083c(Native Method)
at libil2cpp.0xb8dc68(Native Method)
at libil2cpp.0xb8dac8(Native Method)
at libunity.0x566cf4(Native Method)
at libunity.0x574f98(Native Method)
at libunity.0x581a0c(Native Method)
at libunity.0x5815e8(Native Method)
at libunity.0x583620(Native Method)
at libunity.0x583b44(Native Method)
at libunity.0x5844dc(Native Method)
at libunity.0x583870(Native Method)
at libunity.0x58380c(Native Method)
at libunity.0x1d9058(Native Method)
at libil2cpp.0x2bd4b20(Native Method)
at libil2cpp.0x2bd6008(Native Method)
at libil2cpp.0x278083c(Native Method)
at libil2cpp.0xb8dc68(Native Method)
at libil2cpp.0xb8dac8(Native Method)
at libunity.0x566cf4(Native Method)
at libunity.0x574f98(Native Method)
at libunity.0x581a0c(Native Method)
at libunity.0x5815e8(Native Method)
at libunity.0x583620(Native Method)
at libunity.0x583b44(Native Method)

解析后日志:

at libunity.0x577cd8 (ScriptingInvocation::ScriptingInvocation(ScriptingObjectPtr, ScriptingMethodPtr) at ??:?)(Native Method)
at libunity.0x583bdc (MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingExceptionPtr*) at ??:?)(Native Method)
at libunity.0x5844b8 (MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x583870 (MonoBehaviour::StartCoroutine(char const*, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x58380c (MonoBehaviour::StartCoroutineManaged(char const*, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x1d9058 (MonoBehaviour_CUSTOM_StartCoroutineManaged(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*) at ??:?)(Native Method)
at libil2cpp.0x2bd4b20 (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0x2bd6008 (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0x278083c (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0xb8dc68 (BrotliDecoderVersion at ??:?)(Native Method)
at libil2cpp.0xb8dac8 (BrotliDecoderVersion at ??:?)(Native Method)
at libunity.0x566cf4 (scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) at ??:?)(Native Method)
at libunity.0x574f98 (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) at ??:?)(Native Method)
at libunity.0x581a0c (Coroutine::InvokeMoveNext(ScriptingExceptionPtr*) at ??:?)(Native Method)
at libunity.0x5815e8 (Coroutine::Run(bool*) at ??:?)(Native Method)
at libunity.0x583620 (MonoBehaviour::TryCreateAndRunCoroutine(ScriptingObjectPtr, ScriptingMethodPtr, Coroutine**) at ??:?)(Native Method)
at libunity.0x583b44 (MonoBehaviour::HandleCoroutineReturnValue(ScriptingMethodPtr, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x5844dc (MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x583870 (MonoBehaviour::StartCoroutine(char const*, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x58380c (MonoBehaviour::StartCoroutineManaged(char const*, ScriptingObjectPtr) at ??:?)(Native Method)
at libunity.0x1d9058 (MonoBehaviour_CUSTOM_StartCoroutineManaged(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*) at ??:?)(Native Method)
at libil2cpp.0x2bd4b20 (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0x2bd6008 (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0x278083c (__start_il2cpp at ??:?)(Native Method)
at libil2cpp.0xb8dc68 (BrotliDecoderVersion at ??:?)(Native Method)
at libil2cpp.0xb8dac8 (BrotliDecoderVersion at ??:?)(Native Method)
at libunity.0x566cf4 (scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) at ??:?)(Native Method)
at libunity.0x574f98 (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) at ??:?)(Native Method)
at libunity.0x581a0c (Coroutine::InvokeMoveNext(ScriptingExceptionPtr*) at ??:?)(Native Method)
at libunity.0x5815e8 (Coroutine::Run(bool*) at ??:?)(Native Method)
at libunity.0x583620 (MonoBehaviour::TryCreateAndRunCoroutine(ScriptingObjectPtr, ScriptingMethodPtr, Coroutine**) at ??:?)(Native Method)
at libunity.0x583b44 (MonoBehaviour::HandleCoroutineReturnValue(ScriptingMethodPtr, ScriptingObjectPtr) at ??:?)(Native Method)

以上是关于Unity 之 安卓堆栈跟踪和日志工具 (Android Logcat | 符号表解析Bugly捕获)的主要内容,如果未能解决你的问题,请参考以下文章

TraceTool 跟踪工具的瑞士军刀(C++版使用)

符号化没有崩溃日志的 iOS 崩溃堆栈跟踪

在 Spring Boot 应用程序中防止自定义异常的堆栈跟踪日志记录

Tomcat 启动日志 - 严重:错误 filterStart 如何获取堆栈跟踪?

精通springcloud:分布式日志记录和跟踪使用,ELK Stack集中日志

unity如何在安卓端生成日志信息