118

I have two Android devices connected to my computer. When I try to run the app from Android Studio, then it always prompt me to choose the device. Is there any way to deploy the app on a multiple devices automatically - by clicking Run or even better with a shortcut?

tomrozb
  • 25,773
  • 31
  • 101
  • 122
  • Presumably you could script usage of the adb shell `am` command which you can find in the android docs or in numerous questions here, use something like xargs or a for loop to iterate over all the devices, and then configure the IDE to run the script from a custom button or menu. If you are also expecting a (re-) install, you'll need to `adb install -r somefile.apk` in your script first. – Chris Stratton Jul 05 '13 at 21:13

11 Answers11

306

This is almost too easy, actually. When you see the list of devices come up after launching the app, just shift or control click each device you want it to launch on. Just discovered this by accident.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
damccull
  • 3,908
  • 2
  • 17
  • 22
  • 23
    Yes but since this question was never answered, others will now know how to do this. It isn't exactly obvious in the interface. – damccull Jan 22 '14 at 14:11
  • What version of the ide are you running? If you're not running the latest you should update. – damccull Feb 18 '14 at 16:44
  • if you shold shift, select all devices, and you click "Run on the same device next time", even if it doesn't' put plural "devices" it will automatically run on all the next time. – OWADVL Oct 28 '14 at 10:29
  • is there a way to do this on Mac? I wasnt able to select multiple devices. – guness Mar 02 '15 at 13:37
  • @bluebrain I could do it, just did it. Now I feel like a fool for deploying thrice to all 3 Genymotion emulators. – terencey Mar 19 '15 at 10:09
  • I am using Android Studio 1.4 now, and still not able to run my app on two devices at the same time. (on Mac ofc.) – guness Sep 04 '15 at 08:41
  • 12
    Ohh, I just realised that I was trying to debug apps, not run. AS allows to run multi device but debug just one. – guness Sep 04 '15 at 08:44
  • Tip: The use device as default checkbox works with multiple devices. So you don't need to select multiple every run. – Victor Häggqvist Oct 09 '15 at 21:57
  • I've seen this only works for a device and an emulator; not multiple emulators. Are others seeing the same? – Dheeraj Bhaskar Jan 13 '16 at 15:08
  • Just so everyone is aware, Instant Run is not supported when deploying to multiple devices unfortunately. – edwoollard Oct 26 '16 at 13:41
  • Is there a similar option available for running tests? – schlenger Feb 05 '18 at 08:06
  • There is no device selection dialog in latest canary build (3.7), we have to select devices each time we run. – Raghav Satyadev Mar 25 '19 at 13:26
30

For new users, in Android Studio 2, you also need to disable "Instant Run" in Settings->Build, Execution, Deployment->Instant Run. See Instant Run.

With Instant Run, you only can work with one device at time.

UPDATE

In Android Studio 2.1, it is automatically disabled when run in multiples devices at time.

Deploying to multiple devices

Instant Run uses different techniques to perform hot, warm, and cold swaps that are specific to the API level of the target device. For this reason, while deploying an app to multiple devices at once, Android Studio temporarily turns off Instant Run.

9

I got new update of Android Studio that is Android Studio 3.5

Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 9, 2019
JRE: 1.8.0_202-release-1483-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows Server 2016 10.0

In this update they have added in-built option to run application on multiple devices.

The IDE has a new drop-down menu that lets you quickly select which device you'd like to deploy your app to. This menu also includes a new option that lets you run your app on multiple devices at once.

enter image description here

Do update new version of Android Studio and Enjoy.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
  • 17
    Unfortunately, this doesn't remember your selection, so you need to reselect them each time you run. – Ryan R Aug 21 '19 at 16:50
  • 13
    Yeah, this update is the reason I am here. It makes it worse, because the workaround and remember does not work anymore. Lets check the 3.6 Canary Release Notes :-) – Christian Ruppert Aug 22 '19 at 19:38
  • Yep, was not the first one, for a follow up see here: https://stackoverflow.com/questions/57613864/new-issue-after-update-to-android-studio-3-5-release-adb-device-selection-scree – Christian Ruppert Aug 22 '19 at 19:42
  • 3
    I don't enjoy it not remembering selection in multiple devices and trying to run on an emulator if a newly plugged in device hasn't been recognized yet. They once again fixed something that was never broken. Sigh. – Grishka Sep 01 '19 at 17:58
  • 2
    @RyanR it now does remember, Arctic Fox Canary 1 has this feature, bettern than ever :) – avalancha Dec 07 '20 at 12:15
  • @RyanR right now i have three devices and once i select two of them for run then every time i don't have to reselect them and another thing is that you can create shortcut for opening selection menu so that you don't have click every time on device name button to select `run on multiple button` option.. – Vivek Thummar Apr 21 '21 at 09:48
  • @VivekThummar Excellent! – Ryan R Apr 21 '21 at 17:44
5

Just as a point of addition, if you want to run your tests on multiple devices, you can't select multiple devices in the device chooser dialog for a Test profile. Instead, you need to run the gradle command connectedCheck. This runs your tests on all devices connected. There's no embedded UI for it (like you get running tests on a single device), but it provides a link to a locally generated HTML file with the test summary.

You can run from command line, or within AS, look in the Gradle projects window under: App(or root project)->Tasks->verification.

Ref: https://stackoverflow.com/a/18592367/1544046: Describes for emulators, but works for devices as well

Community
  • 1
  • 1
JCricket
  • 1,318
  • 2
  • 17
  • 34
3

This feature is now available in Android Studio 4.2.0. Just "Select Multiple Devices..." as shown in the screenshot below.

Device Selection

Devices are remembered and the multi selection dialog does not need to be opened each time, deploy defaults to previous selection

Only caveat is that devices that are unplugged are not remembered on re-plug

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
avalancha
  • 1,457
  • 1
  • 22
  • 41
2

In Android Studio Select Dropdown option as shown below, you can select Run on Multiple Devices

enter image description here

Now Select Checkbox, in my case I have selected two Samsung phones available and then click on Run button. This will install and launch application in both the devices.

enter image description here

P.S: I have tested this in Android Studio 4.0, but in every run you need to use mouse in Below Android Studio 4.1.1. From Android Studio 4.1.1, there is a option to set KeyMap.

In Android Studio 4.1.2, you can set KeyMap Shortcut key for Run on Multiple Devices. I have set ctl+alt+R in my case as shown in below:

enter image description here

Shiv Buyya
  • 3,770
  • 2
  • 30
  • 25
0

As of Android Studio 2.3.3 Disable the Instant Run use Menu Run->Run App (in windows shift +click for device you want to deploy)

you can't deploy to multiple devices if you used run->debug app

Sam
  • 6,215
  • 9
  • 71
  • 90
0

It's easy to run all connected device every time. Just Select all connected device while Android Studio shows Select Deployment Target & Select "Use same selection for future launches".

N.B. Remember all devices run sequentially one by one.

enter image description here

Shihab Uddin
  • 6,699
  • 2
  • 59
  • 74
0

In Android studio 3.5. Run on multiple devices.

enter image description here

linkaipeng
  • 483
  • 7
  • 9
0

Android Studio 2020.3.1 has the option to run on multiple devices, But we can find multiple runs by selecting multiple devices while selecting the device(s) to run.

Run -> Select Multiple Devices -> Check devices want to run

enter image description here

-4

Very Simple.

CTRL + Shift on every device.

That all

Richard Kamere
  • 749
  • 12
  • 10