【问题标题】:logcat not showing debugging messageslogcat 不显示调试消息
【发布时间】:2016-12-02 19:58:18
【问题描述】:
Android Studio 中的

logcat 未显示我通过 Log.v/.d 生成的输出或在未处理的运行时异常(如空指针)之后的任何堆栈跟踪,并且在应用程序崩溃时没有进一步的信息。 Log.i/.w/.wtf/.e 消息有时会显示。还会显示来自 Android 类的 selfgenerated 消息(仅有时!)和 Android 系统输出(通常始终显示在 logcat 中)。

logcat 过滤器设置为“详细”和“无过滤器”或“仅显示选定的应用程序”(两者都不能解决我的问题)。搜索掩码中没有输入任何内容。重启没有解决问题。

我用 Android 5.1/6 和几个项目/应用尝试了不同的智能手机和模拟器。

示例代码(仅显示比调试更重要的消息):

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);
    Log.v(TAG, "verbose test");
    Log.d(TAG, "debug test");
    Log.i(TAG, "info test");
    Log.w(TAG, "warn test");
    Log.wtf(TAG, "what a terrible failure test");
    Log.e(TAG, "error test");
}

编辑:上述代码的 logcat 输出(带有“详细”和“仅显示选定的应用程序”过滤器选项):

12-02 22:01:13.531 14717-14717/? I/art: Late-enabling -Xcheck:jni

12-02 22:01:13.593 14717-14730/de.kinoblub.testapp E/HAL: load: id=gralloc != hmi->id=gralloc

12-02 22:01:13.621 14717-14717/de.kinoblub.testapp W/System: ClassLoader referenced unknown path: /data/app/de.kinoblub.testapp-1/lib/arm64

12-02 22:01:13.624 14717-14717/de.kinoblub.testapp I/InstantRun: Instant Run Runtime started. Android package is de.kinoblub.testapp, real application class is null.

12-02 22:01:13.717 14717-14717/de.kinoblub.testapp W/System: ClassLoader referenced unknown path: /data/app/de.kinoblub.testapp-1/lib/arm64

12-02 22:01:13.837 14717-14717/de.kinoblub.testapp I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl

12-02 22:01:13.883 14717-14717/de.kinoblub.testapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable

12-02 22:01:14.031 14717-14717/de.kinoblub.testapp I/de.kinoblub.testapp.Main2Activity: info test

12-02 22:01:14.031 14717-14717/de.kinoblub.testapp W/de.kinoblub.testapp.Main2Activity: warn test

12-02 22:01:14.031 14717-14717/de.kinoblub.testapp E/de.kinoblub.testapp.Main2Activity: what a terrible failure test

12-02 22:01:14.044 14717-14717/de.kinoblub.testapp E/de.kinoblub.testapp.Main2Activity: error test

12-02 22:01:14.067 14717-14717/de.kinoblub.testapp I/HwSecImmHelper: mSecurityInputMethodService is null

12-02 22:01:14.167 14717-14747/de.kinoblub.testapp E/HAL: load: id=gralloc != hmi->id=gralloc

12-02 22:01:14.167 14717-14747/de.kinoblub.testapp I/OpenGLRenderer: Initialized EGL, version 1.4

12-02 22:01:14.235 14717-14717/de.kinoblub.testapp I/HwSecImmHelper: mSecurityInputMethodService is null

【问题讨论】:

  • 您使用的是华为设备吗?

标签: java android android-studio logcat


【解决方案1】:

这种情况经常发生,将 logcat 过滤器设置更改为“详细”和“仅显示选定的应用程序”,这对我有用,我希望它也对你有用。

【讨论】:

  • “详细”被选中,“仅显示选定的应用程序”也不起作用。
  • 尝试 Invalidate Cache 并重新启动,然后将 logcat 设置为“详细”和“仅显示选定的应用程序”。
  • 完成。没有帮助:(
【解决方案2】:

这是常见的问题。 检查您是否连接了正确的设备,您正在调试正确的进程,清除过滤栏。

【讨论】:

    【解决方案3】:

    如果您在模拟器或其他设备上调试您的应用程序,是否会出现同样的问题?如果没有,您可能需要更改设备的日志记录输出级别。当您通过 Android Studio 实际调试应用程序时,它会以某种方式降低,但一旦崩溃就会重置为默认手机的级别。

    另一个解决方法是开始使用一些基于 log4j 的记录器(例如logback)并将其配置为将日志写入所需级别的文件。如果应用程序崩溃(在下一个应用程序启动时),您还可以捕获 Thread.UncaughtExceptionHandler 并将日志发送到电子邮件或服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-03
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 2016-02-03
      • 2016-11-15
      • 1970-01-01
      相关资源
      最近更新 更多