首页 > 解决方案 > Log for android app in play console vitals

问题描述

I have an app in google play and for some reason, I get a rare IllegalArgumentException for a method with multiple args. It happens in 0.004% according to google statistics (in my app usage), so there is no way I can reproduce it to know how to solve it, and google play vitals doesnt provide any usable info to what arg was a NULL.

There are a lot of log.X (x = d, e, w...) and I know the basics, but what I dont understand is, can I use some of them to get info on an argument that was NULL when user was using the app? Can I write a log.e("TAG", arg4.toString()), put it in try/catch block and build it for production, so when crash happens, it will print the value of arg4 in google play vitals?

If not, how do I find out which arg was NULL in such a rare case?

标签: androidlogginggoogle-play-console

解决方案


Play Console 中的 Vitals 部分报告崩溃,而不是日志,因此您可以捕获异常并在消息中抛出另一个包含更多数据的异常,但 AFAIK 异常消息通常会在显示在 Play Console 中之前被删除,以防万一它揭示了有关用户的私人数据。

另一种选择是与 Firebase 集成并存储和收集数据,但这可能是值得投入的更多努力。

如果我是你,我会检查源代码(你的应用程序、你正在使用的库或 Android 源代码)哪一行引发了非法参数异常,并检查在这一行检查了哪些参数。

最后,如果这不是一个选项,您可以在调用该方法之前自己在代码中抛出异常,检查每个参数是否为非空。根据抛出的行,您将知道哪个参数为空。


推荐阅读