How to remove and restart the application on the device using Android Studio?

I'm new to Android Studio, and I feel like I should be doing something wrong. When MyApp is launched on a real device, the process is as follows.

  • Change the code.
  • Select the Run command in Android Studio. (Shift + F10)
  • Discover the error (on the phone)
  • Go to Settings → Application → MyApp (on the phone)
  • Force Stop (on the phone)
  • Delete MyApp (on the phone)
  • Change code
  • Select the Run command in Android Studio.
  • Repeat again and again.

This is repeated and time consuming. Is there any way to remove MyApp via Android Studio?

If there is no other more automated way to do this?

BTW I saw this question How to automatically remove the Android application from the device before installing the new version , but this does not allow to solve the problem sufficiently.

+5
source share
3 answers

You can skip the stop and delete step by simply clicking run again. Android Studio will offer you which device will work, and there you can select the connected device.

It will close the application and restart the modified version.

+3
source

I think this answer is what you are looking for. Basically change the configuration to perform the uninstall before starting the application.

In the menu "Run" → "Change configurations" → "Before starting" → Add Gradle -aware Make → ": app: uninstallAll"

+37
source

I always just click on the debug icon (error icon), and on the debug tab (at the bottom of the screen) you can stop the application from launching by clicking the stop button. No need to uninstall / reinstall the application. When you are done, you can build apk.

+2
source

Source: https://habr.com/ru/post/1214014/


All Articles