Android Studio : How To Uninstall APK (or Execute Adb Command) Automatically Before Run Or Debug?
Answer :
adb uninstall <package_name>
can be used to uninstall an app via your PC. If you want this to happen automatically every time you launch your app via Android Studio, you can do this:
- In Android Studio, click the drop down list to the left of Run button, and select Edit configurations...
- Click on app under Android Application, and in General Tab, find the heading 'Before Launch'
- Click the + button, select Run external tool, click the + button in the popup window.
- Give some name (Eg adb uninstall) and description, and type
adb
in Program: anduninstall <your-package-name>
in Parameters:. Make sure that the new item is selected when you click Ok in the popup window.
Note: If you do not have adb in your PATH environment variable, give the full path to adb in Program: field (eg /home/user/android/sdk/platform-tools/adb).
example
adb uninstall com.my.firstapp
List the packages by:
adb shell su 0 pm list packages
Review which package you want to uninstall and copy the package name from there. For example:
com.android.calculator2
Lastly type in:
adb uninstall com.android.calculator2
and you are done.
Comments
Post a Comment