What is this LogCat that you speak of?

//What is this LogCat that you speak of?

On a recent engagement, I assisted one of our clients with configuring Azure DevOps pipelines for a cross platform Xamarin forms application.  Due to the specific requirements of each platform, it is necessary to configure separate pipelines for Android and iOS.

When we got to the Android pipeline, we ran into a bit of a snag.  When we were creating the build and running it locally, we were able to sign the build and install it via Visual Studio to a physical device and the application would run fine. However, when we ran the same build through the Azure pipeline and deployed the app to the same device via Microsoft App Center, the application would hang at startup.  We were unable to utilize the Visual Studio debugger to find out what was going because as I said before the application would run fine locally.  This led me down the path of trying to find a way to see what the app was doing on the physical device after the install.

I did some research and found a very handy utility that you may not be aware of.  When you are doing Android development you install the Android SDK’s that allow you to run the necessary emulators and build code on your laptop before pushing the code to the physical device.  Inside of that SDK is a very useful tool that can tell you exactly what your physical device is doing.

The Android SDK and Tools can be found here: https://developer.android.com/studio/

Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the Log class.

To view the logs of your device, connect your Android device to your laptop.  Assure that your device has USB Debugging enabled.  Now let’s find where our Android SDK is installed…

For me this was: c:\Program Files (x86)\Android\android-sdk\platform-tools

Inside this directory you will see an application called adb.  This is the android debug bridge that allows us to communicate with our device.

Open a command prompt and change directory to the path where you see the adb application.

Then to verify that your device is connected type the following command :  adb devices

You will see your device attached as shown below.

Now to see what is happening on your physical device we utilize the logcat command utilizing the adb.

Type the following command : adb logcat

This will then fill your screen with a rolling log of what is happening on your device.  Now run your application and you will be able to see any errors that are being thrown into your stack traces.

 

Here is a link to additional information about LogCat that may be beneficial.  There are many additional switches and parameters that can be passed to further filter your log output.

https://developer.android.com/studio/command-line/logcat

I hope that you found this post helpful and feel free to reach out to us here at Nebbia for any of your DevOps or Custom Development needs.

By |2018-10-18T10:52:33+00:00October 11th, 2018|

About the Author:

Jeff is an Azure Cloud / Dev Ops Consultant with notable success directing a broad range of IT initiatives while participating in planning and implementation of cloud first solutions. He has a proven track record of increasing responsibility in production support, systems analysis and design and has worked in large organizations such as Raymond James Financial, American Express and Bloomin Brands. Jeff also leads the Tampa PowerShell User Group and actively blogs at Scriptwarrior.wordpress.com and can be reached on Twitter @ScriptWarrior.