Unity的程序build到android一体机后,仿佛进入了一个黑箱子,你既看不到脚本的debug报错信息,也看不到任务管理器里的内存和CPU使用情况?如果黑屏、闪屏、花屏怎么办?
最近面临的一个问题就是:APP在android一体机上频繁闪退和卡死,卡死的时候,出现黑屏甚至花屏!
也知道需要用到adb工具,但是每次打印log信息,只能打印系统级别的log信息,没有脚本级别的debug信息,所以想管中窥豹也不行了!
举例:读取一体机日志并保存到指定目录[d:\myLog.txt]里
adb shell logcat -v time > d:\myLog.txt
adb logcat -s Unity ActivityManager PackageManager xinnengyuan
参考资料:
详细信息请前往:Build Settings
常用的BuildSettings选项
设置的项目 | 作用 |
---|---|
Development Build | Enable this setting to include scripting debug symbols and the Profiler in your build. When you enable this, Unity sets the DEVELOPMENT_BUILD scripting define. You should use this setting when you want to test your application |
Autoconnect Profiler | Enable this setting to automatically connect the Unity Profiler to your build. This setting is only available if you enable Development Build. |
Deep Profiling Support | Enable this setting to turn on Deep Profiling in the Profiler. This makes the Profiler instrument every function call in your application and returns more detailed profiling data. When you enable Deep Profiling Support, it might slow down script execution. This setting is only available if you enable Development Build. |
Script debugging | Enable this setting to allow your script code to be debugged. Not available on WebGL. This setting is only available if you enable Development Build. |
Scripts Only Build | Enable this setting to only rebuild the scripts in your application, and reuse data files from the build you previously executed. Before you can use this setting, you must build your whole Project once. The Scripts Only Build option significantly improves iteration times if you only changed the code in your application. This setting is only available if you enable Development Build. |
adb logcat -s Unity ActivityManager PackageManager xinnengyuan DEBUG
adb logcat -s Unity ActivityManager PackageManager xinnengyuan DEBUG > d:\myLog2.txt
使用方法:
第一步:输入以上的命令,开启adb监听
第二步:在VR一体机上操作app,直到黑屏、花屏,甚至冒烟炸机…
第三步:用【Ctrl + C】结束adb监听
第四步:到D盘下,查看你的myLog2.txt文档,你将会在D盘发现这个胖嘟嘟的可爱的日志文件:)
第五步:分析日志文档
寻找到的报错信息(节选);