Android
App Development
Command Line
Debugging
Mobile Apps

Stopping an Android app from console

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

If you need to stop an Android app from the console, the usual tool is ADB, the Android Debug Bridge. The exact command depends on what you mean by "stop": force-stop the package, kill its process if possible, or clear its data and restart from a clean state.

The most direct command: am force-stop

For development and testing, the standard way to stop an app is:

bash
adb shell am force-stop com.example.myapp

This tells Android's Activity Manager to force-stop the package. It is the closest command-line equivalent to force-stopping the app from system settings.

This is usually the answer people want.

When you have multiple devices connected

If both an emulator and a physical device are attached, specify the target device explicitly:

bash
adb devices
adb -s emulator-5554 shell am force-stop com.example.myapp

That avoids sending commands to the wrong target.

force-stop versus kill

Android also exposes commands such as:

bash
adb shell am kill com.example.myapp

But kill is not the same as force-stop. In practice:

  • 'force-stop is stronger and prevents the app from receiving further implicit launches until explicitly started again'
  • 'kill is more limited and may not behave the way you expect for every app state'

For most automation and debugging cases, force-stop is the more reliable choice.

Starting the app again

If you want to restart the app after stopping it, you can launch the main activity explicitly.

bash
adb shell am start -n com.example.myapp/.MainActivity

If you are not sure about the main activity, Android Studio, adb shell dumpsys package, or the manifest can help you identify it.

For example, package inspection can help during debugging:

bash
adb shell dumpsys package com.example.myapp

That output is noisy, but it is often enough to confirm package metadata and launcher activity details when you are scripting device actions.

Clearing app data as well

Sometimes you do not just want the process stopped. You want the app reset to a clean state.

bash
adb shell pm clear com.example.myapp

That removes the app's local data, which is much more destructive than a simple stop. It is useful for repeatable test runs, but you should not use it casually.

Common developer workflow

A common console workflow during testing is:

bash
adb shell am force-stop com.example.myapp
adb shell pm clear com.example.myapp
adb shell am start -n com.example.myapp/.MainActivity

That gives you a fresh launch from a clean state.

Common Pitfalls

The biggest mistake is confusing the package name with the app label. com.example.myapp is the package identifier, not the name shown on the launcher icon.

Another issue is using pm clear when you only meant to stop the app. pm clear deletes app data, sign-in state, preferences, and local storage.

It is also easy to forget device targeting when several phones or emulators are connected. ADB will complain or hit the wrong device unless you specify one clearly.

Finally, avoid force-stopping system apps unless you know exactly what you are doing. That can destabilize the device or interfere with the test environment.

Summary

  • Use adb shell am force-stop your.package.name to stop an Android app from the console.
  • 'force-stop is usually more reliable than am kill for app-level stopping.'
  • Use adb -s DEVICE_ID ... when multiple devices are connected.
  • 'pm clear resets app data and is much more destructive than a simple stop.'
  • Restart the app with adb shell am start -n package/.Activity when needed.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.