Logcat won't display Log.d messages

余生长醉 提交于 2019-11-28 23:24:08

It might because of some phones disabled log to enhance performance.

For example, my phone HUAWEI P9 lite, i have to do the following steps to make Log.d works:

  1. Dial *#*#2846579#*#*
    • The number might vary, you should do some search to get secret code for your phone.
  2. Come to ProjectMenu page
  3. Click Background Settings
  4. Click LOG Settings
  5. Check AP Log.
  6. For unknown reason, it automatically checked all logs when reopen LOG Settings.

[UPDATE]

Just now it happen again after I pull from git, adb shell shows this:

open '/dev/hwlog_switch' fail -1, 13. Permission denied
log switch off, only log_main and log_events will have logs!

I test with new project and it got log, only this old project has issue. I tried rebuild the app, re-enable the log steps above, and even reboot phone, but still no luck.

Then I uninstall the app (Or all relevant productFlavors apps) in phone and reinstall, the log was back.

On some models you have to go to the developer options, and select "Allow all", on "Advanced logging".

The following screenshot is from my Meizu MX 4 Pro:

Today, I faced the same issue. Nothing worked for me as mentioned solutions. But what worked for me is in Android Studio Right side at the bottom as mentioned in the image. Select the option as mentioned in the image. After that everything was working as expected. Now posting my solution it may help others.

Hope that helps others

Did you have enabled USB debugging for logcat ? (if your physical device is connected by USB cable). Go to "settings", then "applications", then "development", then check "USB debugging".

Then it should appear in DDMS. Just select it to debug/see logs.

Maybe not an answer, but need to show pictures. Try to set a Filter for Your TAG like this:

and select verbose option:

does this help?

You need to set logging (to the desired level) through the adb shell as follows:

  1. Navigate to the platform-tools in your android sdk folder.
  2. Open the adb shell using ./adb shell for linux/mac/windows powershell or just adb shell for windows cmd.
  3. Issue the following commands:

     stop
     setprop log.tag.MYTAG VERBOSE
     start 
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!