122

I know how to install the apk file in to the emulator by command prompt and all that. But i want to know is it possible to install same apk file in to multiple emulator by giving any specific name ? Actually i have to test one apk file in to many device. and for that i have started many device. I know how to install it. if the all device are open then it will not get install. So is there any alternate to install that apk file by giving any specific device Emulator id or any name ??? Please help me if there is any idea for it. . . Thanks.

Roope
  • 4,469
  • 2
  • 27
  • 51
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188

6 Answers6

307

Yes, you can install an apk on a particular device.

In command, type:

adb devices
// list of devices and its unique ID...

Then type:

adb -s "<deviceIDfromlist>" install "<path-to-apk>"
decates
  • 3,406
  • 1
  • 22
  • 25
Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • 2
    Device id means that number ?? that appears on the device as like 5554 or 5556... as like ??? – Shreyash Mahajan Aug 25 '11 at 07:07
  • 2
    yes, the number you are getting after executing adb devices – Mohammed Azharuddin Shaikh Aug 25 '11 at 07:09
  • Thanks. I got it. But is that "deviceIDfromlist" is that device number listed as 5554 or 5556 or like that ?? or anything different number ?? – Shreyash Mahajan Aug 25 '11 at 07:13
  • I am not getting install... if i have mention the install path in command prompt then should i again have to give the path after install keyword ??? – Shreyash Mahajan Aug 25 '11 at 07:28
  • i have written as adb -s 5554 install anyapplication.apk – Shreyash Mahajan Aug 25 '11 at 07:29
  • adb -s emulator-5554 install c:\anyapplication.apk or any, but must be specific path – Mohammed Azharuddin Shaikh Aug 25 '11 at 07:31
  • 1
    @djaqeel: i was new to android at that time. Now i know all that very well. – Shreyash Mahajan Aug 16 '13 at 06:12
  • what will be the command when I have to install it from playstore or from server.? – ELITE Mar 07 '16 at 15:54
  • With this instalation way, the apk or the app can only run on the specified device. I mean if someone can clone the app or the apk and instal it on other device, the app would run or it wouldn't run due to the app was specified for other device. – jose920405 Jul 08 '16 at 18:59
  • 3
    And if you need to know which device is which you can use `adb devices -l` which will give you more information about each device like this: `c1cd3890098c08f0 device usb:337641472X product:rubenswifixx model:SM_T360 device:rubenswifi transport_id:5 0123456789ABCDEF device usb:336592896X product:HR935 model:HR935 device:HR935 transport_id:3` – Joshua Pinter Jan 12 '18 at 18:13
21

Step 1: Get the device Ids of all connected device

adb devices

Step 2: Install to a particular device you want to install

adb -s deviceId install path+apk

Example:

Step 1:

C:\Android\android-sdks\platform-tools>adb devices

List of devices attached emulator-5554 device 014FD87107021017
device

Step 2:

C:\Android\android-sdks\platform-tools>adb -s 014FD87107021017 install C:\Users\
user\Documents\appname.apk
Mostasim Billah
  • 4,447
  • 3
  • 19
  • 28
Vinayak
  • 6,056
  • 1
  • 32
  • 30
  • we should use some pipelining or script to do all commands sequentially – Vinayak Jul 29 '14 at 12:43
  • 2
    For Windows, here's a quick 1 liner : `FOR /F "skip=1" %x IN ('adb devices') DO start adb -s %x install -r myandroidapp.apk` .If you plan on including this in a batch file, replace %x with %%x, as : `FOR /F "skip=1" %%x IN ('adb devices') DO start adb -s %%x install -r myandroidapp.apk` – zingh Mar 14 '18 at 19:23
9

Use the following scripts to install apk on multiple devices/emulators.

    for SERIAL in $(adb devices | grep -v List | cut -f 1);
    do adb -s $SERIAL install -r /path/to/product.apk;
    done

Remove -r if you are not reinstalling the apk. Also you can replace "install -r /path/to/product.apk" to other adb commands like working on one single device.

It works for me on real devices but I believe it should also works for emulators.

mlchen850622
  • 668
  • 6
  • 7
7

It is possible to issue install command simultaneously on all connected devices.

The key is to launch adb in a separate process (&).

I came up with the following script to simultaneously fire-off installation on all of the connected devices of mine and finally launch installed application on each of them:

#!/bin/sh

function install_job { 

    adb -s ${x[0]} install -r PATH_TO_YOUR_APK
    adb -s ${x[0]} shell am start -n "com.example.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

}


#iterate over devices IP-addresses or serial numbers and start a job 

while read LINE
do
    eval x=($LINE)
    install_job ${x[0]} > /dev/null 2>&1 &
done <<< "`adb devices |  cut -sf 1`"

echo "WATING FOR INSTALLATION PROCESSES TO COMPLETE"
wait

echo "DONE INSTALLING"

Note 1: the STDOUT and STDERR are suppressed. You won't see any "adb install" operation result. This may be improved, I guess, if you really have to

Note 2: you could also improve script by providing args instead of hardcoded path and activity names.

That way you:

  1. Don't have to manually perform install on each device
  2. Don't have to wait for one install to finish in order to execute another one (adb tasks are launched in parallel)
Drew
  • 3,307
  • 22
  • 33
  • i appreciate your answer. But hotveryspicy is right for what i have asked. I have also updated my question so that other don't have wrong clue for what i am asking. Really thanks for answer. +1 from my side to your answer because it also help in another manner. – Shreyash Mahajan Feb 04 '15 at 13:11
  • Thanks for the feedback, I corrected the answer – Drew Feb 04 '15 at 13:31
  • No your answer is right in case if someone wants to install the apk file in one go... – Shreyash Mahajan Feb 04 '15 at 13:33
2

yes you can install your apk file in multiple emulator for that you have to give the name in command prompt here is the link for guidance

http://developer.android.com/guide/developing/tools/emulator.html

Pratik
  • 30,639
  • 18
  • 84
  • 159
0

You can install on multiple devices at a time using USB debugging.

In Eclipse Run--> Run Configurations --> choose your project (on left) -->Target --> Launch on All compatible devices.

The selected project will be installed on all the connected devices

Vinay
  • 1,284
  • 14
  • 24