Android Studio Logcat仅显示Firebase Analytics日志问题求助
我明白你被这个Logcat只显示Firebase Analytics日志的问题困扰好几天了,试过了各种办法都没效果,咱们一步步来排查和解决:
首先先梳理下你已经尝试过的操作,避免重复:
- 清除缓存并重启设备/Android Studio
- 重启Logcat面板
- 撤销USB调试授权后重新连接
- 选择Logcat的“无过滤器”选项
- 重新安装应用
- 切换日志级别(Verbose/Error/Debug)
- 在开发者选项中增大日志缓冲区大小
从你提供的日志来看,确实只有Firebase Analytics(FA标签)的日志输出,完全看不到你应用自身的日志。接下来可以试试这些针对性的解决方案:
1. 检查应用代码中的日志实现
确保你是用Android官方的android.util.Log类来输出日志,比如:
Log.d("MyWalletTag", "用户打开了首页");
如果用了自定义的日志工具,检查它的内部实现是否正确调用了Log类的方法,有没有被意外关闭日志输出。
另外,如果你开启了Debug版本的代码混淆(minifyEnabled true),ProGuard/R8可能会移除日志语句,你可以在proguard-rules.pro中添加规则保留日志:
-keepclassmembers class * { public static android.util.Log *; }
2. 确认Android Studio的Logcat进程选择
有时候会不小心选中了其他进程(比如系统进程或Firebase相关进程),你需要确保Logcat顶部的进程选择器里,选中的是com.tashila.mywalletfree.debug这个进程,也就是你自己的应用进程。
3. 用adb命令直接排查日志
脱离Android Studio,在终端里运行以下命令,直接通过adb查看你应用的日志:
adb logcat -s MyWalletTag:V *:S
把MyWalletTag替换成你应用里实际用的日志标签。如果这个命令能输出你应用的日志,说明问题出在Android Studio的Logcat配置上;如果还是看不到,那问题就出在应用本身或者系统限制上。
4. 检查厂商系统的日志限制
小米、华为等定制Android系统可能会有日志限制功能,比如开发者选项里的“禁止权限监控”“日志输出限制”等选项,你可以去开发者选项里找一找,关闭这类限制后再试试。
5. 检查Logcat的隐藏过滤规则
有时候会不小心设置了正则过滤或者其他隐藏规则,你可以点击Logcat搜索框旁边的过滤按钮,选择“Edit Filter Configuration”,检查有没有添加了只显示FA标签的规则,或者删除所有自定义过滤器,重新选择“无过滤器”。
附上你提供的日志内容:
Logcat(日志级别:Verbose | 仅选中应用)
2020-11-29 20:03:05.165 18576-18615/com.tashila.mywalletfree.debug V/FA: App measurement collection enabled 2020-11-29 20:03:05.168 18576-18615/com.tashila.mywalletfree.debug V/FA: App measurement enabled for app package, google app id: com.tashila.mywalletfree.debug, 1:615339790521:android:a54ce30e1047dc49fdcb68 2020-11-29 20:03:05.169 18576-18615/com.tashila.mywalletfree.debug I/FA: App measurement initialized, version: 33025 2020-11-29 20:03:05.169 18576-18615/com.tashila.mywalletfree.debug I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE 2020-11-29 20:03:05.170 18576-18615/com.tashila.mywalletfree.debug I/FA: To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.tashila.mywalletfree.debug 2020-11-29 20:03:05.170 18576-18615/com.tashila.mywalletfree.debug D/FA: Debug-level message logging enabled 2020-11-29 20:03:05.218 18576-18608/com.tashila.mywalletfree.debug V/FA: onActivityCreated 2020-11-29 20:03:05.255 18576-18615/com.tashila.mywalletfree.debug V/FA: Connecting to remote service 2020-11-29 20:03:05.286 18576-18615/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:03:05.300 18576-18615/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:03:05.635 18576-18615/com.tashila.mywalletfree.debug I/FA: Tag Manager is not found and thus will not be used 2020-11-29 20:03:05.672 18576-18615/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:03:05.969 18576-18615/com.tashila.mywalletfree.debug V/FA: Activity resumed, time: 1034755035 2020-11-29 20:03:06.027 18576-18615/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:03:06.030 18576-18615/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:03:06.710 18576-18615/com.tashila.mywalletfree.debug D/FA: Connected to remote service 2020-11-29 20:03:06.711 18576-18615/com.tashila.mywalletfree.debug V/FA: Processing queued up service tasks: 6 2020-11-29 20:03:11.837 18576-18615/com.tashila.mywalletfree.debug V/FA: Inactivity, disconnecting from the service 2020-11-29 20:05:02.316 18576-18681/com.tashila.mywalletfree.debug V/FA: Recording user engagement, ms: 116300 2020-11-29 20:05:02.329 18576-18681/com.tashila.mywalletfree.debug V/FA: Connecting to remote service 2020-11-29 20:05:02.579 18576-18681/com.tashila.mywalletfree.debug V/FA: Activity paused, time: 1034871354 2020-11-29 20:05:02.696 18576-18681/com.tashila.mywalletfree.debug V/FA: Connection attempt already in progress 2020-11-29 20:05:02.700 18576-18681/com.tashila.mywalletfree.debug D/FA: Connected to remote service 2020-11-29 20:05:02.702 18576-18681/com.tashila.mywalletfree.debug V/FA: Processing queued up service tasks: 2
“运行”标签页日志
11/29 20:50:59: Launching 'app' on Xiaomi Redmi Note 8. App restart successful without requiring a re-install. $ adb shell am start -n "com.tashila.mywalletfree.debug/com.tashila.mywalletfree.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 23766 on device 'xiaomi-redmi_note_8-142ae1cf'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. V/FA: App measurement collection enabled V/FA: App measurement enabled for app package, google app id: com.tashila.mywalletfree.debug, 1:615339790521:android:a54ce30e1047dc49fdcb68 I/FA: App measurement initialized, version: 33025 To enable debug logging run: adb shell setprop log.tag.FA VERBOSE To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.tashila.mywalletfree.debug D/FA: Debug-level message logging enabled V/FA: Connecting to remote service V/FA: onActivityCreated V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress I/FA: Tag Manager is not found and thus will not be used V/FA: Connection attempt already in progress V/FA: Activity resumed, time: 1037630815 V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 6 V/FA: Inactivity, disconnecting from the service V/FA: Connecting to remote service D/FA: Connected to remote service V/FA: Processing queued up service tasks: 1 V/FA: Inactivity, disconnecting from the service V/FA: Recording user engagement, ms: 72971 V/FA: Connecting to remote service V/FA: Activity paused, time: 1037703790 V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 2
内容的提问来源于stack exchange,提问作者Tashila Pathum

