How To Get The Crash Logs Of Android Applications?

More and more people are using smartphones today, hooked on Android, IOS, and Windows commonly. This calls for advanced features, applications in smartphones like interesting games, banking, media, chat messenger, and much more. Life has become simpler with the advent of new mobile technology. Using desktop or laptops to access applications can now be done over mobile, which helps us save time and effort.

Realizing this advantage, the IT organizations have now drifted towards developing the mobile versions (IOS, Windows, and Android Applications) of the web applications.

I have a question for the mobile testers, did you ever face any error like- ‘Unfortunately application(name) stopped’ as displayed in the below figure?

Unfortunately application(name) stopped

What Does This Error Mean?

This error means there is a crash in the mobile application (IOS, Windows, and Android Applications). The whole application has stopped working.

When Do You Get This Error?

If you are a Mobile tester, this type of error will show up when,

  • Application is in the developing phase

  • The application is being used by users or on server crashes.

Having said this, sometimes the “Crash” error occurs randomly. For instance, if you are testing a mobile application and suddenly you faced “Unfortunately application(name) stopped and you will try to reproduce the same error but you fail.

We are not sure, as an Android application will not get a crash in the production environment since you were not able to take the logs of the random crash.

Don’t worry, you can easily get the logs of android application crashes and show them to a developer so that they can easily fix the crashes on time and the user will not be able to face the crash error in the production environment.

Here is an easy way to capture the crash logs of Android Applications…

There are a lot of ways to take the crash logs of Android applications. I would like to suggest you use ADB to get the crash logs by using Command Prompt. I will show you the working of ADB step by step.

What is ADB?

Before going into detail, let’s have a quick introduction to ADB. ADB is an Android Debugging Bridge through which you can communicate with a device (Device may be an Emulator or a real connected device). The ADB command provides multiple facilities like installing and debugging apps and you can also use it to run a command on an android device. ADB is basically a client-server program.

ADB allows you to remold your device (or device’s software) via a PC command line. In this article, we will run the commands to get the crash logs.

Prerequisites for ADB:

A) Java:

Java is mandatory before starting the ADB. If updated Java is already available in your system, you don’t need to install it. You can check if Java is available or not in your system as given in the below figure:

Open the Command Prompt-> Type “Java -version” command->Enter

If Java is not present in your system, you can download it from the below link:

https://java.com/en/download/

B) Android SDK Platform-Tools:

Being a tester, you need to only download Android SDK Platform Tools instead of the complete ADT bundle. You can download it from the below link:

https://developer.android.com/studio/releases/platform-tools.html

Download and Keep the folder on any drive.

Need to set the Environment Variables for Java and Android SDK:

C) Environment Variables for Java:

You need to add an environment variable for Java when Java is not accessible in your system. You can refer to the link below to add them:

https://stackoverflow.com/questions/1672281/environment-variables-for-java-a

D) Environment Variables for Android SDK:

You can add environment variables by following steps which are available in the below link:

http://www.software-testing-tutorials-automation.com/2015/09/set-androidhome-and-path-environment.html

How Will You Use ADB?

Now that you have the environment ready to use the ADB, get ready to use ADB to catch the crash logs of the android application whenever you face a crash error on your device. For average users, the only time you will require to use ADB is when you have step-by-step instructions.

A) Enable “USB Debugging” Option of Android Devices:

To use ADB with a device connected via USB, you must enable the USB debugging option in the device system settings, under Developer options.

On Android 4.2 and higher, the Developer options screen is invisible by default. To make it visible, go to Settings > About phone and tap Build number seven times. You need to go back to the previous screen to find Developer options at the bottom of the screen.

B) Connect your Device:

Now connect your android device or Emulator devices with the host computer via USB cable.

C) Access Android-SDK Folder:

1. Open the Command Prompt.

2. The most important thing to know how to access your ADB folder via commands. This is done with the cd (change directory) command. So if (on Windows) your SDK folder is called android-SDK and it’s in your root (c:) directory or you can keep the “android-SDK” folder in any other directory like D, E, and more.

I have given the name of the “android-SDK” folder to “Platform-tools”. So, you would type the following commands to get into the platform-tools folder:

C:\Users\(Username)> cd Platforms-tools

List of connected devices:

C:\Users\(Username)\Platforms-tools> ADB devices

If everything is set up properly, you will see a list of devices attached as shown in the below figure:

ADB Devices list in Command Prompt

Crash Logs:

Now you require to type the command “adb logcat AndroidRuntime:E *:S” to get the crash logs of the android applications. You can see crash logs in the below image:

ADB Crash Logs for Android in Command Prompt

In the above figure, the highlighted content is exhibited “Command to take crash” and crash logs. So you can report the error to a developer to get it fixed. This is the main step of this article.

Key Advantage of ADB:

Though there are many advantages, I am going to explain one which can be used to install the android applications. It will be good for you if you will install the “.apk” file via ADB rather than doing manually. So you need to follow below steps:

1. Keep the “.Apk” file in any folder on the host computer.

2. Connect the Android device to which you want to install the “.apk” file with the host computer.

3. Open the command prompt, type command “Adb Install” and give a path to the folder where the “.Apk” file is available in the folder as shown in the below figure:

Type command Adb Install and give a path to the folder where the .Apk file is available

The high pointed content “Success” in the above figure shows the installation status of an application.

Is ADB best to get the crash logs of Android Applications?

Yes, ADB is really the best tool for both developers and testers which is a great thing in itself. ADB can be used to install and debug Android applications. It helps to automate the applications.

In this article, we have learned how to get the crash logs of Android applications only. If you want to learn how it will use in Automation Testing. So you can learn from the below link:

http://toolsqa.com/mobile-automation/appium/appium-tutorial/

Do you think, is this easy way to get the crash logs of android applications??? Let your opinions matter in the comments section below.

Latest posts by Rahul Huria (see all)

6 thoughts on “How To Get The Crash Logs Of Android Applications?”

Leave a Comment