在Android Studio中的发布版本上启用LogCat

在Android Studio中的发布版本上启用LogCat

问题描述:

默认情况下,当我将Build Variants更改为release时,logcat上没有任何日志,但是我确实需要读取应用程序的发布日志,如何启用此功能?

By default, when I change Build Variants to release I don't get any Logs on the logcat, but I do need to read release logs of my app, how can I enable this?

<application>标记内的清单中添加android:debuggable="true"(默认为false).

Add android:debuggable="true" (default is false) to your Manifest inside the <application> tag.

从文档中获取:

android:debuggable
是否可以调试应用程序, 即使在以用户模式运行的设备上,如果可以,则为"true",并且 如果不是,则为"false".

android:debuggable
Whether or not the application can be debugged, even when running on a device in user mode — "true" if it can be, and "false" if not.

分别

您可以通过删除android:debuggable属性来禁用调试 从清单文件中的标记,或通过设置 清单文件中的android:debuggable属性设置为false.

You can disable debugging by removing the android:debuggable attribute from the tag in your manifest file, or by setting the android:debuggable attribute to false in your manifest file.

编辑

您可能需要在android {...}标签内的build.gradle文件中添加以下内容:

Edit

You may need to add the following to your build.gradle file inside the android{...} tag:

lintOptions {
   checkReleaseBuilds false
}

作为旁注:无论设备的 debuggable 是否设置为 false ,始终在设备上始终写入日志>或 true .但是通过Android Studio中的 LogCat ,只有将debuggable设置为true才有可能. (刚刚测试过)

And as a side-note: Right on the device the Logs are always written, no matter if your application's debuggable is set to false or true. But via the LogCat in Android Studio it's only possible if debuggable is set to true. (Just tested this)