Skip to content
Related Articles

Related Articles

Improve Article

How to Uninstall APK Automatically Before Run or Debug in Android Studio?

  • Difficulty Level : Expert
  • Last Updated : 23 May, 2021
Geek Week

In this article, we will discuss how we can uninstall the APK from the android device before we run or debug the app in android studio. We almost have to test that when a new user comes to our app, he/she will be shown a first-time login/welcome screen. To test this feature, we have to uninstall the app before we proceed to show the latest changed code in the Android Studio. The prerequisite of this topic is you must have Android Studio installed on your device. So, let’s start by creating an android project first.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Simply Run the Hello World App on your emulator

After successful build.

Step 3: Now click on the Run/Debug button to install the app on the emulator or device the first time.



Note: You may refer to this article: Running your first Android app in Android Studio

After successful build.

Method 1

Now follow the steps to make android studio automatically uninstall the app before launch

Note: Add Path of adb to environment variables - C:\Users\{Username}\AppData\Local\Android\Sdk\platform-tools
  1. Open Android Studio, click the app button on top, and click “Edit Configurations”.
  2. Find the “Before launch” section and click the “+” button.
  3. Select “Run External Tool” from the dropdown.
  4. Again click the “+” button.
  5. Type “adb” in program field, and “uninstall <package-name>” in arguments. 

Now the app will be uninstalled and will be launched again the first time.

Method 2 

  • Click “Tools” from the navbar and click “SDK Manager” now select “plugins” from the list.
  • Now search for “adb idea” in the marketplace search bar.

Now to uninstall the app click “tools” and click adb idea and from the dropdown select adb uninstall, the app will be successfully uninstalled.

App successfully uninstalled.

Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!
My Personal Notes arrow_drop_up
Recommended Articles
Page :