Android ADB Install / Uninstall App Examples

This article will tell you how to use ADB ( Android Debug Bridge) to install or uninstall apk file on android devices. You can read the article How To Use Android Debug Bridge (ADB) to learn more if you do not know about android ADB.

1. Use ADB To Install Android Apps Apk File.

1.1 Push app apk file to android device.

//Push to system app folder
adb push example.apk /system/app.

//Push to user app folder
adb push example.apk /data/app.

This method has below disadvantages.

  1. Maybe overwrite the original app, so you had better use below command to backup the original app before operation.
    // Pull android apk from device to local folder.
    adb pull /system/app/example.apk    /user/app_bak
  2. Usually, you can encounter below error messages.
    failed to copy '/user/example.apk' to '/system/app/example.apk': Read-only file system.
    

    This is bacause /system/app folder is read-only, you can not push files into this folder.

    To resolve this problem, you need to use adb install command with -r option to force install the apk files, we will introduce it below.

    // -r means force install.
    adb install -r /user/example.apk
    

    Above adb install apk file command will install the apk file into /data/local/tmp/ directory.

1.2 Use adb install command.

  1. Startup android emulator.
  2. Run adb install apk file command as below to push android app into emulator /data/app directory.
    adb install C:/work/example.apk
    
  3. Click the android app icon to run it on the android emulator screen.

2. Use ADB To Uninstall Android Apps Apk File.

2.1 Use ADB Uninstall App Apk File Command.

You can find the android app package name use android device monitor. The package name is located in /data/data folder.
You can refer article Android Device Monitor Cannot Open Data Folder Resolve Method to learn how to use android device monitor.

// Below command will return all the android app packages installed on the connected android device.  
adb shell pm list packages -f -3 
// uninstall android app by app package name.
adb uninstall <app package name>
> adb uninstall com.dev2qa.example
Success

2.2 Use ADB Shell Command.

> adb shell 
generic_x86:/ # cd /data/app
generic_x86:/data/app # rm com.dev2qa.example.apk

3. Uninstall Android App In Emulator.

You can also use android emulator to uninstall installed android apps.

  1. Click Settings —> Apps.
    uninstall-android-app-click-settings-apps
  2. Click the android app that you want to uninstall in app list.
    android-app-list
  3. Click uninstall button in app info panel.
    click-uninstall-button-in-app-info-panel

4. How To Uninstall Android Apps Automatically Before Run / Debug Android App In Android Studio.

  1. Click Run / Debug —> Edit Configurations ( for Windows ) menu item at android studio top menu bar to open the Edit Configurations window.
  2. If you run android studio on macOS, click Run —> Run / Debug menu item, then it will popup a dialog, click Edit Configurations menu item in the popup dialog to open the Edit Configurations window.
    open edit configurations window in android studio macos version
  3. Select the android app in the popup window left side Android Application section.
  4. Go to the Before launch area on right-bottom of the popup window, click the + button then select Run External Tool from the dropdown list.
    android studio - edit run configuration - select android app - general tab - before launch - run external tool
  5. Above action will popup another External Tools management dialog, click the + button at bottom of the popup dialog to add an external tool.
    android studio - run configuration - before launch - list external tools dialog
  6. In the next popup window, input related information to run the external tool. For example, Name : Uninstall App Before Launch,  Group : External Tools, Description :  It will uninstall android app before launch android app, Program : adb ( or the adb command absolute path if you do not set the path in system environment variable ), Arguments : uninstall app_package_name, etc.
    android studio - run configuration - before launch - edit external tool
  7. Click OK button to save above configuration, and check the External Tool ( Uninstall App Before Launch ) in the External Tools list dialog.
    android studio - run configuration - before launch - list external tools dialog
  8. Now the adb uninstall command will be executed every time you start to run the app in android studio.

1 thought on “Android ADB Install / Uninstall App Examples”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.