1. Problem
Sometimes when we start the app, the app crashes, and the log in android studio may be flushed, or the app installed on the mobile phone of the cloud platform does not have android stduio at all, so what method can we use to quickly know the startup crash log?
2. Solution
We first need a terminal in the linux environment. If it is a linux environment, open the terminal directly. If it is a windows environment, we download git and then open git bash to simulate the linux environment. We can open 2 terminals at the same time
A terminal filters the full log, that is, when the app starts, we save the full log of the phone
adb logcat > log.txt
Another terminal immediately filters the process name of the current app
adb shell ps | grep packagename
We know that the process id is 14312, and then we use the grep command to filter the keyword 14312
grep 14312 log.txt > keep.log
Then we open the keep.log file, we can know that the contents of this file are basically the logs printed by the app when it starts, and we can analyze the crash logs.
We compare the sum of the number of rows before and after the log
$ cat log.txt | wc -l
86146
$ cat keep.log | wc -l
7478