You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

All Errors in One Place

0.00 avg. rating (0% score) - 0 votes

When we release an Android app on Play Store, we constantly track error logs, crashes and ANRs via different mediums.

1. Playstore: We check our Playstore console regularly for statistics and crash reports.

2. Our common error logging system (Newmonk): To ensure our app is working fine and users are not facing any technical issues, we collect error logs using our own error handling module. We regularly check this interface as well.

We follow a Roster programme wherein the team members take turns to monitor app health and constantly look for solutions to optimize the efforts being spent by engineers. Hence we decided to create a solution that will bring all kinds of errors, Playstore crashes and ANRs at one place.

We need to perform three steps to achieve this,

1. Write an automation script to download crashes and ANR reports from Playstore daily.

2. Write a generic code which parses all types of downloaded reports for all projects in a required format.

3. Send parsed data to common error logging interface.

Download reports from Playstore console

Reports are available from Google Cloud Storage. Reports are generated daily and accumulated in monthly CSV files. They are stored in a private Google Cloud Storage bucket for your Google Play Developer account. These reports can be accessed programmatically using gsutil tool. By installing this tool and setting up credentials as mentioned in the documentation, you can access all your reports. A simple shell script like below can be scheduled to download reports daily.


month=$(date +”%Y%m”);

filename=”crashes_<your pkgname>_${month}.csv”;

downloadpath=”<path where you want to download reports>”;

<path-to-google-cloud-sdk>/bin/gsutil cp gs://<your google cloud storage bucket id>/crashes/${filename} ${downloadpath}

Parse reports                                                    

We have to parse csv files in such a way that we can get an array list of records containing different  fields

1. Initiate result list object and read the input

ArrayList<String[]> resultList = new ArrayList();

BufferedReader reader = null;

reader = new BufferedReader(new InputStreamReader(inputStream, “UTF-16”));

2. Begin reading records from crashes csv file

 String csvLine;csvLine = reader.readLine();

while( csvLine = reader.readLine())!= null) {

3. Skip blank lines

if(csvLine.isEmpty() || csvLine.trim().equals(“”) || csvLine.trim().equals(“\n”)) // do nothing

4. Replace commas within quotes with pipes to avoid parsing errors.                             Since a record’s fields are comma separated , so we have to replace comma with another character unless it is a field separator

else {  String csvLineWithCommasInsideQuotes  csvLine;

String csvLineWithoutCommasInsideQuotes = new String();

boolean inQuotes = false;

for(inti=0i<csvLineWithCommasInsideQuotes.length(); ++i){

 if (csvLineWithCommasInsideQuotes.charAt(i)==‘”‘)  inQuotes = !inQuotes;

if (csvLineWithCommasInsideQuotes.charAt(i)==‘,’ &&inQuotes)

csvLineWithoutCommasInsideQuotes += ‘|’;

else  csvLineWithoutCommasInsideQuotes +=

csvLineWithCommasInsideQuotes.charAt(i);  }

5. Now we can safely split the record on comma and retrieve all the field

String[] row = csvLineWithoutCommasInsideQuotes.split(“,”);


6. And we have all the crashes in resultList.

Send parsed data to error logging interface

Since play store maintains month wise reports they get updated daily. So, we have to read the same csv file every day for incremental changes. For that we have to maintain an index file containing an index value which will indicate the last position in file. Update the index file after sending error logs. For a new month, set this index to zero.

Now read parsed csv data from previous step and prepare post parameters and body to be sent on error logging server.

After receiving error logs, error logging server will process the data, verify and show us the logs on interface.

Now you can see all error logs at one place like this –


This way by collating data from different sources to a single place, we not only save the bandwidth of Roster person but can also create custom alerts to notify us in time.


Posted in Mobile