Arrêter l'application Android

VérifiéSûr

Arrête proprement une application Android sur l'appareil connecté en utilisant la commande 'adb shell am force-stop'. Utile pour le débogage, les tests ou le nettoyage avant un nouveau déploiement. Cette méthode préserve les données de l'application.

Spar Skills Guide Bot
DeveloppementDébutant
6002/06/2026
Claude CodeCursorWindsurf
#android#adb#force-stop#debugging

Recommandé pour

Notre avis

Arrête une application Android sur un appareil connecté via la commande adb force-stop pour une terminaison propre pendant le développement.

Points forts

  • Termine proprement tous les processus de l'application sans supprimer les données
  • Peut être exécuté plusieurs fois sans erreur même si l'application n'est pas en cours d'exécution
  • S'intègre facilement dans les workflows de déploiement et de test
  • Utilise la commande Android framework pour un arrêt propre plutôt qu'un kill OS

Limites

  • Nécessite ADB installé et un appareil connecté avec le débogage USB activé
  • Ne stoppe qu'une seule application spécifique (le nom du package doit être connu)
  • Ne supprime pas les données de l'application ; une commande séparée est nécessaire pour cela
Quand l'utiliser

Utilisez cette compétence lorsque vous devez arrêter l'application avant d'installer une nouvelle version, de redémarrer ou de tester depuis un état de processus propre.

Quand l'éviter

Ne l'utilisez pas si vous devez réinitialiser complètement les données de l'application (SharedPreferences, bases de données) – utilisez plutôt 'pm clear'.

Analyse de sécurité

Sûr
Score qualité85/100

The skill uses adb shell force-stop for legitimate Android app termination, with no destructive, exfiltrating, or obfuscated commands. It is standard tool usage for development.

Aucun point d'attention détecté

Exemples

Stop Android app for redeployment
Stop the Android app currently running on the device so I can install a new version.
Kill app process only
Kill the app without removing its data, using force-stop via adb.
Terminate before restart
Terminate the Android app, then restart it after making some config changes.

name: android-stop-app description: Stop the Android app running on connected device. Cleanly terminates the app using force-stop. Use when stopping the app for debugging, testing, or cleanup.

Android Stop App

Overview

Stops the Android app running on a connected device by using adb shell am force-stop. This cleanly terminates all app processes, clearing memory while preserving app data.

When to Use

Invoke this skill when the user:

  • Asks to "stop the Android app"
  • Wants to "kill the app"
  • Says "terminate the Android app on device"
  • Mentions shutting down or closing the Android app
  • Needs to stop before deploying new version

Prerequisites

  • Android device connected via USB
  • USB debugging enabled
  • ADB installed (brew install android-platform-tools)
  • Device authorized
  • App must be running on the device

Instructions

  1. Navigate to the Android app directory:

    cd path/to/android/app
    
  2. Run the stop script:

    ./stop-app.sh
    
  3. The script will:

    • Use adb shell am force-stop to terminate the app
    • Report success
  4. Inform the user:

    • The app has been stopped
    • Safe to call even if app isn't running
    • Uses force-stop for clean shutdown (not kill)

Expected Output

🛑 Stopping NoobTest on device...
✅ App stopped

How It Works

The script uses:

  • adb shell am force-stop com.miso.noobtest

This Android framework command:

  • Stops all processes associated with the package
  • Clears app from memory
  • Preserves app data and settings
  • Clean shutdown (not emergency kill)

force-stop vs kill

force-stop (recommended):

  • Android framework command
  • Clean shutdown
  • Preserves app data
  • Safe for development

kill (not recommended):

  • OS-level signal
  • Abrupt termination
  • May leave resources in inconsistent state
  • Only use if force-stop fails

Common Use Cases

Before deploying new version:

./stop-app.sh
./install-device.sh

Pairing with restart:

./stop-app.sh
# Make configuration changes
./restart-app.sh

Clean state testing:

./stop-app.sh
# Clear app data manually if needed
adb shell pm clear com.miso.noobtest
# Then install fresh

Common Issues

"no devices found":

  • Check USB connection
  • Ensure USB debugging enabled
  • Verify authorized: adb devices
  • Try: adb kill-server && adb start-server

"adb: command not found":

  • Install Android platform tools: brew install android-platform-tools
  • Check PATH includes adb

App still running after force-stop:

  • Rare, but check with: adb shell pidof com.miso.noobtest
  • If still running, restart device
  • Or use: adb shell pm clear com.miso.noobtest (nukes app data too)

Safety

This script is safe to call repeatedly:

  • Won't error if app isn't running
  • Uses clean shutdown method
  • Reports status clearly
  • No risk to app data or installation

Package Name

The script is configured for the specific app's package name (e.g., com.miso.noobtest for Firefly/NoobTest). Package name is defined in build.gradle.kts under applicationId.

Data Preservation

force-stop does NOT clear:

  • App installation
  • App data (SharedPreferences, databases, files)
  • App permissions
  • User settings

To fully clear app state, use:

adb shell pm clear com.miso.noobtest

But this will require reinstallation and setup.

Skills similaires