Logcat log warning/errors

前端 未结 2 1474
名媛妹妹
名媛妹妹 2021-01-19 20:19

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

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 20:53

    Is that normal?

    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.

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

    Example...

    package com.mycompany.mypackage
    
    public class MyActivity extends Activity {
    
        protected final String TAG = getClass().getName();
    
    }
    

    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.

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

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

提交回复
热议问题