1, problem,

Sometimes when we start the APP, the APP crashes. The log may be washed out in Android Studio, or the APP installed on the mobile phone of the cloud platform does not have Android STduio at all. Then, how can we quickly know the startup crash log?

2. Solutions

If it is Linux, just open the terminal directly. If it is Windows, download Git and open Git bash to simulate Linux. We can open both terminals at the same time

A terminal filters the full log, that is, when the app starts, we save the phone’s full log

adb logcat > log.txt
Copy the code

The other terminal immediately filters the process name of the current app

adb shell ps | grep packagename
Copy the code

We know that the process ID is 14312, and then we use grep to filter the keyword 14312

grep 14312 log.txt > keep.log
Copy the code

Then we open the keep.log file, we can know that the content in this file is basically the log printed by the app startup, we can analyze the crash log.

Let’s compare the total number of rows before and after the log

$ cat log.txt | wc -l
86146
Copy the code
$ cat keep.log | wc -l
7478
Copy the code