Logcat 日志警告/错误 [英] Logcat log warning/errors

查看:41
本文介绍了Logcat 日志警告/错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过 ADB 连接我的 Galaxy s3 mini 并尝试使用 android studio 调试应用程序时,我在 logcat 中收到无穷无尽的错误/警告消息,不间断的消息就像疯了一样.这是正常的吗?通常使用模拟器,我不会在 logcat 中收到大量消息.我该如何解决这个问题?这是 logcat 的样子 http://pastebin.com/JaVhYaCthttp://i.imgur.com/aaavMZm.png?1

When I connect my galaxy s3 mini via ADB and try debug application with android studio I get endless error/warning messages in logcat, non-stop messages goes like crazy. Is that normal? Usually with emulator I don't get tons of message in logcat. How can I fix this problem? here's how logcat looks like http://pastebin.com/JaVhYaCt or http://i.imgur.com/aaavMZm.png?1

顺便说一句:我仍然可以测试应用程序.

By the way: I still able to test applications.

推荐答案

这正常吗?

是的 - 系统本身以及每个应用程序都使用日志记录,这就是您所看到的.准系统模拟器不会有很多带有接收器和服务运行的应用程序,因此您不会看到相同数量的日志记录.

Yes - the system itself as well as every app uses logging and that's what you're seeing. A bare-bones emulator won't have many apps with receivers and services running so you won't see the same amount of logging.

我该如何解决这个问题?

How can I fix this problem?

您不能这样做,但您可以通过从设备上的设置"强制关闭各种应用程序来减少它.不一定是个好主意,但这是您的选择.

You can't as such but you can reduce it by force closing various apps from "Settings" on the device. Not necessarily a good idea but it's your choice.

您可以通过在代码中使用包 TAG,然后应用过滤器以仅显示带有 TAG 的 logcat 数据来改进事情.

You can improve things by using package TAGs in your code and then applying a filter to only show logcat data with your TAGs.

示例...

package com.mycompany.mypackage

public class MyActivity extends Activity {

    protected final String TAG = getClass().getName();

}

在上面的 TAG 中将是com.mycompany.mypackage.MyActivity".使用 protected 作为修饰符,因此任何扩展 MyActivity 的类都会自动将它们自己的类名分配给 TAG.

In the above TAG will be "com.mycompany.mypackage.MyActivity". Use protected as the modifier so any classes which extend MyActivity will automatically assign their own class name to TAG.

记录时您只需使用`Log.d(TAG, "Some text");

When logging you just use `Log.d(TAG, "Some text");

然后,您只需要过滤com.mycompany.mypackage"以仅查看来自您自己的应用组件的日志记录.

You then just need to filter on "com.mycompany.mypackage" to only see logging from your own app components.

这篇关于Logcat 日志警告/错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆