logcat没有显示调试信息

3
在Android Studio中,logcat无法显示我通过Log.v/.d生成的输出或任何未处理的运行时异常(例如nullpointer)后的堆栈跟踪,当应用程序崩溃时也没有进一步的信息。有时会显示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

您正在使用华为设备吗? - npace
3个回答

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

已选择“冗长模式”,同时“仅显示选定应用程序”也无法正常工作。 - False
尝试使缓存失效并重新启动,然后将logcat设置为“详细”和“仅显示选定的应用程序”。 - Samurai21
完成。没有帮助 :( - False

0

这是一个常见的问题。 请检查您是否连接了正确的设备,正在调试正确的进程,并清除筛选栏。


0

如果您在模拟器或其他设备上调试应用程序时没有遇到同样的问题,那么您可能需要更改设备的日志输出级别。当您实际调试Android Studio应用程序时,输出级别会被降低,但在崩溃后会重置为默认手机级别。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接