HOW TO

Export a crash log (logcat) from an Android device

Last Published: November 2, 2021

Summary

When using Esri products for the Android mobile platform and the application crashes, the generated log files (logcat) can be retrieved to perform diagnostics and troubleshooting. However, as not all of these products have Developer mode enabled by default, the log files can only be retrieved using the Android SDK Platform-Tools.

Note:
Some Esri apps offer troubleshooting logs that can be obtained from the app that can help with troubleshooting errors (see the screenshots below from Field Maps as an example). This article explains the workflow to export device logs, not logs specifically from a certain app.
navigating to log files in ArcGIS Field Maps

Procedure

The following workflow can be performed for non-rooted Android devices to extract the log files. However, prior to reproducing the error to generate and extract the log file, Developer mode must be activated on the Android device. A computer is required to perform the extraction.

Warning:   
This workflow involves using  Android SDK Platform-Tools and is not supported by Esri.
  1. On the Android device, navigate to Settings > About device, and tap the Build Number option seven times to enable developer mode.
Note:
On some Android devices, the Build Number option can be accessed via Settings > About phone > Software information.
navigating to Android Developer options
  1. Navigate back to the Settings menu > System > Advanced, and open Developer options, and enable the USB debugging option.
turning on USB debugging
  1. For Android devices running on versions 5.0 or later, increase the Logger buffer sizes to 4 MB per log buffer.
Note:
4MB is sufficient for storing the logs. However, this can be increased as needed.
setting buffer size for logging
  1. Open the mobile application and reproduce the error. This generates the log file.
  2. Connect the Android device to a computer with a USB cable. You may get a prompt on your device to allow access to phone data.
Connecting the Android device to a computer
  1. Create a folder on your computer to store the logs in, for example, C:\AndroidLog.
  2. Download Android SDK Platform Tools, and extract the contents to the computer.
  3. Open the extracted platform-tools folder and ensure adb.exe exists.
  4. Press Ctrl + Shift , right-click the empty workspace area, and select Open command window here, or Open PowerShell window here.
2021-10-27_7-34-59.jpg
  • In Windows 10, you may not have the option to Open command window here when pressing Ctrl + Shift and right-clicking. You have the option to use PowerShell instead.
  • If for any reason you need to use the Windows Command Prompt, you can go to the Taskbar settings and disable the option to replace Command Prompt with Windows PowerShell.
  • You can open a Command Prompt as admin by right-clicking the Windows Start menu.
2021-11-01_9-11-17.jpg
2021-11-01_9-13-27.jpg
  1. In the command prompt/PowerShell, perform the following command:
    1. Change the output path in the sample code below to the folder you created in step 6.
    2. Specify a name for a text file to export the logs (with .txt extension).
adb logcat -v threadtime -d > C:\AndroidLog\logcat.txt
running the command in Powershell
running in the Command Prompt window
Note:
If the command failed with an error like this:
"adb : The term 'adb' is not recognized as the name of a cmdlet, function, script file, or operable program.", try running the same command with ".\adb" instead of "adb", as follows.
.\adb logcat -v threadtime -d > C:\AndroidLog\logcat.txt
Powershell command revised2021-10-27_8-53-39.jpg
Note:
When the export process is started, you may get a prompt on your phone to allow USB debugging. You must click OK to allow debugging.
prompt to allow allow USB debugging
  1. The log file (logcat.txt) is now extracted to the destination folder using verbose logging.
logcat.txt in the file browser
Note:
For more information on understanding the log file, refer to Reading Bug Reports.

Article ID:000017058

Software:
  • Apps
  • ArcGIS Runtime SDK for Android

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic