0

I have an issue just now where my Android app can't be redeployed without first killing the previous, still running, build (i.e. hitting the app switch button in the emulator and swiping my app upwards to kill it).

If I were able to automate it using a Gradle build script, it would be a workaround, but good enough. Has anyone done something like this before?

Chucky
  • 1,701
  • 7
  • 28
  • 62
  • What do you currently mean by "first killing the previously running build."? – Martin Marconcini Mar 10 '22 at 11:45
  • Edited my question for clarity – Chucky Mar 10 '22 at 18:20
  • Normally, uploading a new APK to the device does already kill the app, right? – Thomas Mar 10 '22 at 18:26
  • 1
    That might be the case, but killing it deliberately is the only way to get around the deploy error I'm experiencing "Couldn't terminate the existing process for [myapp]". More details here: https://issuetracker.google.com/issues/181004316 – Chucky Mar 10 '22 at 18:40

1 Answers1

0

After reading more about the issue on Google Tracker, I now better understand the problem.

First and foremost, next time you post a question, consider adding all this information upfront, it would have helped narrow it down without you having to go back and forth for 5 days with no answer.

Now back to your problem, there's no way (that I can recall) to explicitly emulate the task swipe action you manually perform. A perhaps better workaround could be to add an intent to your app that you can send during your build, so it will "auto terminate"; now depending on what your app is, "terminating itself" may be a simple case of stopping any services, and finishing all the activities, but this may be insufficient and you'll have to play with it. Remember to make this intent filter secure and behind a feature toggle you can disable in prod if that's needed... you only want this for your eyes only ;)

If that doesn't work, I am not sure there's more you can do without resorting to hack and slash something via some script. But then again, you'd need privileges to let the Android OS let you "kill" a process; that's why I'm suggesting you try to let the process kill itself before trying something hacky and prone to fail. Alternatively, Google could "fix" the issue, but considering how long some issues are there in the tracker with "no update", I'd start considering an alternative while you can. My bet is in a few weeks a Google person will reply with "please provide a sample project with the latest AStudio", ignoring the previous 30 people who posted the same simple repro steps. Hopefully that won't be the case with your issue here. Good Luck.

Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144