androidengineers.Book a session

Professional Skills

Debugging in Android Studio

article30 minMedium

Debugging is the process of understanding why the app behaves differently from what you expected. Good debugging is calm, systematic, and evidence-based.

Start With The Error

If the app crashes, open Logcat and find the exception.

Common crash types:

ErrorMeaning
NullPointerExceptionYou used a missing value
IndexOutOfBoundsExceptionYou accessed a bad list index
IllegalStateExceptionAn API was used in the wrong state
SecurityExceptionMissing permission or restricted access

Read the first useful line that points to your app code.

Logcat

Add logs when you need runtime visibility.

Log.d("LoginViewModel", "Submit clicked with email=$email")

Do not leave noisy logs everywhere. Use them to investigate, then clean them up or make them meaningful.

Breakpoints

A breakpoint pauses the app at a line of code. Use Debug instead of Run, click next to a line number, and inspect variables when execution stops.

Breakpoints are great for:

  • checking function inputs
  • following branch decisions
  • inspecting API responses
  • verifying state updates

Step Through Code

Use:

  • Step Over: run current line
  • Step Into: enter a function
  • Step Out: finish current function
  • Resume: continue app execution

Layout Inspector

When a composable looks wrong — wrong size, unexpected clipping, invisible overlap — use the Layout Inspector.

Go to View → Tool Windows → Layout Inspector while the app is running. It shows a live view of the composable tree, lets you click any element, and shows the applied modifiers and their values.

This is much faster than guessing at padding and size values.

Debugging Compose State

For Compose bugs, ask:

  • Is the state actually changing?
  • Is the composable reading the right state?
  • Is state duplicated in two places?
  • Is a list mutated instead of replaced?

Practice

Create a counter app with a deliberate bug: clicking the button does not increase the number. Use logs and breakpoints to find why.

Summary

Debugging is a core engineering skill. Learn Logcat, stack traces, breakpoints, stepping, and state inspection. The faster you can find truth, the faster you can build.

YOUR LEARNING JOURNEY

0 of 22 available lessons completed

Progress saved in this browser. No account needed.
Debugging in Android Studio | Junior Android Developer | Android Engineers