在Android Studio中的发布版本上启用LogCat [英] Enable LogCat on Release Build in Android Studio

查看:610
本文介绍了在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)

这篇关于在Android Studio中的发布版本上启用LogCat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆