18

In Android studio 2.0 after first app launch on emulator it seems that run process is attached to it. But if I connect device and want to test app, device chooser dialog is not showing up. I tried instant run, simple run, checked configurations (it's set to show chooser dialog), but all changes are made to emulator app.

How to launch app in device without turning off emulator and losing instant run "**connection**" with emulator ?

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Ragaisis
  • 2,700
  • 1
  • 26
  • 41
  • Did you Unchecked the box "Use same device for future launches" – Rakshit Nawani Apr 11 '16 at 07:03
  • yes, it's always unched. I even tried to check, apply changes, ok. And uncheck apply changed and ok – Ragaisis Apr 11 '16 at 07:07
  • Well that's unusual. Try to close and re open your Android Studio – Rakshit Nawani Apr 11 '16 at 07:08
  • This problem has been driving me batty ever since I updated! I frequently use as many as 4 devices at a time, and the lack of the chooser dialog showing up regularly has almost driven me to go back to AS v1.5. Sigh. – SMBiggs May 30 '16 at 13:33
  • I have the same issue and drives me nuts. I have to install on multiple Emulators and devices in order to test our app but no matter what I do it doesn't let me just run app without the debugger. If I hit the stop button it kills the app on all the devices and emulators. That is just not right. Seems like since 2011 today June 20, 2016 Android Studio did not address this issue which is really bad for the developers... It doesn't stop me from working but a big annoyance and time consuming... It wast e my time... – Vincy Jun 20 '16 at 15:13
  • Please check [this](http://stackoverflow.com/a/37207831/2826147) and [this](http://stackoverflow.com/a/35169716/2826147) answer – Amit Vaghela Aug 02 '16 at 08:36

6 Answers6

30

This behaviour is clearly a shortcoming that's going to be fixed in subsequent releases, there's an open issue at AOSP.

Right now I found two workarounds that don't require studio restart or killing the adb process:

  1. Force close the app on the device you have the ongoing instant-run session. This way the session will be closed and you will be asked to choose the device after next run.

  2. Press the "debug" button if you've pressed the "run" button before and vice versa. For some reason, changing from run to debug or from debug to run forces AS to close the instant run session.

Dmide
  • 6,422
  • 3
  • 24
  • 31
20

Till the issue is solved, you can do this.

In the run menu, there is an option as 'Stop app'. Using that you can force stop your app. Running again you will get the device chooser option.

Your app will be present in your earlier device or emulator. You will just have to re-launch it. (If you do not want to run again on the earlier device.)

Ankita
  • 313
  • 1
  • 8
4

Go to Run>Edit Configurations > Deployment Target Options and uncheck "Use same device for future"

Waqar Khan
  • 468
  • 4
  • 18
1

February 2018 answer: Try to disable Instant run from the Settings, it worked for me on Android-studio v.3.0.1

  1. Open the Settings or Preferences dialog: On Windows or Linux, select File > Settings from the menu bar. (On Mac OSX, select Android Studio > Preferences from the menu bar.)
  2. Navigate to Build, Execution, Deployment > Instant Run.
  3. Uncheck the box next to Restart activity on code changes.

enter image description here

taxo
  • 539
  • 1
  • 3
  • 21
0

Go to Task Manager and kill the adb.exe process.

This will detach the android studio with the running emulator. You can then again run the program and you will see the device chooser.

vipin agrahari
  • 2,691
  • 3
  • 21
  • 31
  • I wish not to turn off android studio (like on previous android studio versions) because it takes time to rebuild app from scratch, and first build is longer than others, so it's not acceptable. – Ragaisis Apr 11 '16 at 07:35
  • The solution that I provided above will not turn off your android studio. It will just reinitialize your adb. – vipin agrahari Apr 11 '16 at 07:45
  • thanks for the clarification, but it's not working too. On mac i killed adb process with activity monitor, but device chooser dialog is not showing up and changes are made to last attached process. So currently I can't choose where I want to run app without killing emulator :/ – Ragaisis Apr 11 '16 at 08:02
-2

Instant Run has nothing to do with emulator or devices, it will perform its action on whosoever you have selected.

Just restart your android studio and connect your device and launch app ; Dialog will appear.
When chooser dialog appears showing connected devices and emulators don't check "Use same device for future launches" to get this dialog every time you launch your app.

Also, if you want to run on all devices hold on SHIFT and click each and run.

Anurag
  • 1,162
  • 6
  • 20
  • Unfortunately that isn't the case, even when you go to `Edit Configurations` it shows `Show Device Chooser Dialog` and `Use same device for future launches` isn't checked yet it still isn't showing. – em_ Apr 20 '16 at 19:56