18

I have 50 apk files and I need to install it to many android devices. How can I install it with one click. I can install an apk file using adb via "install" command but how to install 50 apk files at once?

I'm using Windows

Thanks.

Danylo Volokh
  • 4,149
  • 2
  • 33
  • 40

16 Answers16

29

In Windows, you can using this command line:

for %f in (C:\your_app_path\*.apk) do adb install "%f"
Manoj Khanna
  • 63
  • 1
  • 7
alextooter
  • 349
  • 3
  • 3
  • 2
    For any mac or linux users that stumble on this, a similar command would be `find . -name "*.apk" -exec adb install {} \;` to install all apk files in the current directory (and any subdirectories). – Ben Baron May 31 '18 at 21:06
  • the `adb install-multiple` command did not always work for me, throwing errors here and there. I had to fallback to this command for convenience and guarantee all apks in the folder will be installed. – piouson Jan 02 '22 at 21:01
25

you can either use (from ADB help):

adb install-multiple [-lrtsdpg] <file...>
                             - push this package file to the device and install it
                               (-l: forward lock application)
                               (-r: replace existing application)
                               (-t: allow test packages)
                               (-s: install application on sdcard)
                               (-d: allow version code downgrade)
                               (-p: partial application install)
                               (-g: grant all runtime permissions)

which is prefered over installing one-by-one, since you'll be saving some overhead connection-time over each command connecting/disconnecting to your device's modem,

generally speaking, use the install-multiple while escaping the package name (your apk files), you better make sure the apk files-names do not have spaces or you'll have to escape the file-names. if you are using windows's cmd escaping and wrapping with " is mandatory, unless you are using a little trick: dropping a few apk files over a batch file and using the %* as argument.

if you are still on the "I want to install one-by-one, use my script from the following answer https://stackoverflow.com/a/34553043/257319 it will allow you an unlimited amount of arguments, while properly shortening the apk-file name in the install command..

another alternative is batch compressing the whole APK to a 'storage-compression zip' pushing it to the sdCard, uncompressing it to a tmp folder, and using shell to install the packages one by one, but since those exist locally the overhead of "adb-to-modem conversations" would be almost none :)

happy installation :]

Community
  • 1
  • 1
  • Would `adb install-multiple-package` now be preferred here? The help text for `install-multiple` now says "push multiple APKs to the device for a single package and install them". It looks like the question is about different packages – aloha_erich Jul 27 '23 at 14:51
9

Are you using linux ? You could copy all apks to one directory, and then run simply use:

#!/bin/sh
for file in /dir/*
do
  adb install $file 
done
devconsole
  • 7,875
  • 1
  • 34
  • 42
RobertM
  • 287
  • 1
  • 6
5

This worked for me:

ls *.apk | cut -d' ' -f9 | tr '\r' ' ' | xargs -r -n1 -t adb install

All the APKs were present in the current directory. (performed on Ubuntu)

Lokeshwar Tailor
  • 341
  • 4
  • 12
4

I found the solution. Its actually very simple:

adb install application1.apk & adb install application2.apk & adb install applicaiton3

That's what i was looking for. Thanks everyone

Danylo Volokh
  • 4,149
  • 2
  • 33
  • 40
  • almost, better use `|` instead of `&`. - - The `&` will say "continue to next install if nothing is wrong" but sometimes (unless you choose to force install with `-r`: replace existing application) the package is either installed or corrupted in which case the whole line would stop executing, but in that case the rest of the `install` instructions won't be execute as well, while this is fine for some cases (you want to debug the package that was the case of an error) usually batch installation tend to **love** the **"mass approach"**. Using `|` is just like saying "continue anyway". –  Jan 01 '16 at 00:06
  • This is no longer the correct answer - `adb install-multiple` is the command you need. – Yoel Gluschnaider Nov 07 '20 at 08:31
3

Based (and thanks) on the answer by alextooter and edited by Manoj Khanna

I came up with this:

In Windows, you can using this command line:

for %f in (C:\your_app_path\*.apk) do adb install "%f"

In a batch file:

you can use %%f and "%%f" instead, and after truly long hours working on this, I came up with this pretty neat solution on a batch file:

@echo Preparing to install all .apk files in "C:\My Hardware\Cell Phone\APKs\" folder to device

@pause

@for /f "delims=|" %%f in ('dir /b "C:\My Hardware\Cell Phone\APKs\"*.apk') do @"C:\My Hardware\Cell Phone\ADB\adb.exe" install -r "C:\My Hardware\Cell Phone\APKs\%%f"

@echo End of Batch File

@pause

This batch file gave this output, [notice a couple of errors, because unconventional characters in the file name (™ trade Mark Char and the '&' symbol), but nothing to worry about, that'll be another topic.]

[One final remark. The original folder address was a lot longer that just 'my hardware' and it was edited for illustrative purposes only, if by any chance it was forgotten to edit in some other line(s) then be aware. It was triple checked, but anyways, one never knows.]

so, on with the Screen Output Copy-Paste:

Preparing to install all .apk files in "C:\My Hardware\Cell Phone\APKs\" folder to device

Press any key to continue . . .

2119 KB/s (3730200 bytes in 1.718s)

        pkg: /data/local/tmp/AdAway_v3 (04-2015).apk

Success

2349 KB/s (39102487 bytes in 16.250s)

        pkg: /data/local/tmp/Amazon Kindle_4.13.0.203_1144258763.apk

Success

1681 KB/s (591738 bytes in 0.343s)

        pkg: /data/local/tmp/Apk Extractor_3.04.apk

Success

1824 KB/s (2685472 bytes in 1.437s)

        pkg: /data/local/tmp/CCleaner_v1.11.43_71411143.apk

Success

1433 KB/s (22935 bytes in 0.015s)

        pkg: /data/local/tmp/Contenidos_1.0_1.apk

Success

can't find 'C:\My Hardware\Cell Phone\APKs\Digital clock XperiaT_3.8.0.96_96.apk' to install

2955 KB/s (189128 bytes in 0.062s)

        pkg: /data/local/tmp/DiskUsage_3.5.3_3053.apk

Success

1761 KB/s (873714 bytes in 0.484s)

        pkg: /data/local/tmp/Galactic Core Free_2.41_43.apk

Success

2619 KB/s (11988685 bytes in 4.468s)

        pkg: /data/local/tmp/Gmail_5.3.95312851_53000576.apk

Success

2380 KB/s (2856307 bytes in 1.171s)

        pkg: /data/local/tmp/Goggles_1.9.4_211.apk

Success

2555 KB/s (38071805 bytes in 14.546s)

        pkg: /data/local/tmp/Google App_4.7.13.19.arm_300412076.apk

Success

2467 KB/s (23850128 bytes in 9.437s)

        pkg: /data/local/tmp/Google Keyboard_4.1.22063.1974169_22063.apk

Success

2682 KB/s (9999424 bytes in 3.640s)

        pkg: /data/local/tmp/Google Play Books_3.4.9_30409.apk

Success

2141 KB/s (13604976 bytes in 6.203s)

        pkg: /data/local/tmp/Google Play Games_3.1.11 (2044178-030)_31110030.apk

Success

2689 KB/s (9640324 bytes in 3.500s)

/system/bin/sh:  TV_3.8.8_38081.apk: not found

/system/bin/sh:  TV_3.8.8_38081.apk: not found

2761 KB/s (17101587 bytes in 6.046s)

        pkg: /data/local/tmp/Google Play Music_6.0.1945S.2039625_1945.apk

Success

2694 KB/s (7631202 bytes in 2.765s)

        pkg: /data/local/tmp/Google Play Newsstand_3.2.0_2014040406.apk

Success

2371 KB/s (41779806 bytes in 17.203s)

        pkg: /data/local/tmp/Google Play services_7.5.74 (1997312-030)_7574030.apk

Success

2759 KB/s (13424078 bytes in 4.750s)

        pkg: /data/local/tmp/Google Text-to-speech Engine_3.4.6.1819666.arm_2103
04060.apk

Success

2448 KB/s (34089466 bytes in 13.593s)

        pkg: /data/local/tmp/Google+_5.8.0.96635860_414049433.apk

Success

2499 KB/s (20197317 bytes in 7.890s)

        pkg: /data/local/tmp/Hangouts_3.3.94322993_22401362.apk

Success

2371 KB/s (13280248 bytes in 5.468s)

        pkg: /data/local/tmp/Keep_3.1.204.00_3120400.apk

Success

2672 KB/s (20566942 bytes in 7.515s)

        pkg: /data/local/tmp/Maps_9.10.1_910100121.apk

Success

2292 KB/s (5759074 bytes in 2.453s)

        pkg: /data/local/tmp/Nova Launcher_4.0.1_40100.apk

Success

2515 KB/s (3098485 bytes in 1.203s)

        pkg: /data/local/tmp/Santa Biblia Reina Valera 1960_1.5.3_40.apk

Success

2769 KB/s (4918721 bytes in 1.734s)

        pkg: /data/local/tmp/TalkBack_4.2.0_40200008.apk

Success

1857 KB/s (564672 bytes in 0.296s)

        pkg: /data/local/tmp/Terminal Emulator_1.0.70_71.apk

Success

2266 KB/s (1160352 bytes in 0.500s)

        pkg: /data/local/tmp/Tinycore_3.2.2_22.apk

Success

2221 KB/s (12048716 bytes in 5.296s)

        pkg: /data/local/tmp/WALKMAN_8.3.A.0.2.apk

Success

1667 KB/s (18543284 bytes in 10.859s)

        pkg: /data/local/tmp/WhatsApp_2.12.158_450540.apk

Success

End of Batch File

Press any key to continue . . .
quietmint
  • 13,885
  • 6
  • 48
  • 73
3

If you need a cross platform solution which also works on multiple connected devices simultaneously (with a bunch of convenience features, like finding adb in default location), you can check out this tool:

https://github.com/patrickfav/uber-adb-tools

Usage for install

java -jar uber-adb-tools.jar --install /folder/apks/

console showcase

Does also uninstall multiple packages with wildcard support.

Full disclaimer: I am the developer

Patrick
  • 33,984
  • 10
  • 106
  • 126
1
for file  in ./*.apk;
do
 adb -s deviceserial install $file;
done
Das_Geek
  • 2,775
  • 7
  • 20
  • 26
Victor Choy
  • 4,006
  • 28
  • 35
1

Lokenschwar's answer doesn't take apk names containing spaces. This do also names with spaces.

ls -1 *.apk | xargs -d \\n -r -n1 -t adb install
daru
  • 11
  • 4
0

If you want to do it on a Mac, put all your APKs in a folder and try this in the Terminal:

for file in apk/*; 
do 
./adb install $file; 
done
Sujay Anjankar
  • 321
  • 3
  • 13
0

For Windows do this:

in CMD inside ur folder path run this:

dir /s /b > print.txt

Open the text file and rename all enteries from

c:\......

to

adb install -r c:\....

the file should look like this : (Assuming you are using Notepad to view your "print.txt" file, press "CTRL+H". This will open the Find and Replace dialog box.

adb install -r c:\apps\com.ups.mobile.android-2.apk
adb install -r c:\apps\com.vavni.android.battleship-1.apk

Now you need to rename that .txt extension in your "c:\apps\print.txt" to "print.bat". You need to have extension shown in windows. Google that if you dont know how to do that

http://forum.xda-developers.com/showthread.php?t=743457

Thiago
  • 12,778
  • 14
  • 93
  • 110
0

I've installed 10 apk files on 30 devices with one SDCard and MultiAPKInstaller (available on play store: https://play.google.com/store/apps/details?id=com.bifusimo.multiapkinstaller&hl=pl).

Mr.R.
  • 1
  • 1
0

Use Powershell ISE on Windows 10:

  1. Put all *.apk files in a folder (don't use Space in file names)

  2. Navigate to this folder with

    CD "/your/folder/dir"
    
  3. Type this command:

    (gci -re *.apk).Fullname
    

    This will return all the apk files with full path

  4. Copy all list to the Script pan (on the right or bottom) - then Ctrl+A

  5. Press Ctrl+H to open find and replace

  6. Replace the path before apk file with "adb install " (it has 1 space in the end)

    For example if we have this:

    C:/Users/Username/Documents/APK Folder/first.apk
    C:/Users/Username/Documents/APK Folder/second.apk
    C:/Users/Username/Documents/APK Folder/third.apk
    

    After replace:

    adb install first.apk
    adb install second.apk
    adb install third.apk
    
  7. Select all list again with Ctrl+A

  8. Press F8 on the keyboard or Run Selection on the command bar

    This will install all the apk to the connected device/emulator

RobC
  • 22,977
  • 20
  • 73
  • 80
0

Save the following as a 'something.ps1'. Right Click -> Run with PowerShell.

$startTime = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss'
$fileNames = Get-ChildItem -Path $scriptPath -Recurse -Include *.apk
$log = foreach ($f in $fileNames) { adb install -r $f }
$log | Out-File installation-$startTime.log

A log file will be generate in the end. It will contain all error messages.

Sabaat Ahmad
  • 522
  • 1
  • 5
  • 10
0

I developed script for Windows which installs all apks to all connected devices:

echo off       
setlocal EnableDelayedExpansion           
for /f "tokens=*" %%f in ('C:\android\sdk\platform-tools\adb.exe devices') do (
for /r %%p in (*.apk) do (
set devicestr=%%f
set apk=%%p
if "!devicestr!"=="!devicestr:List=!" (
for /f "tokens=1" %%d in ("!devicestr!") do (
set deviceid=%%d
echo !deviceid!
echo !apk!
C:\android\sdk\platform-tools\adb.exe -s !deviceid! install !apk!
)
)
)
)
Access Denied
  • 8,723
  • 4
  • 42
  • 72
-2

The step by step actions required to execute Alextooter's answer:

On windows 10:

  1. Download adb fastboot here(download link in first post):https://forum.xda-developers.com/showthread.php?t=2317790

Minimal ADB and Fastboot_techbeasts.rar

  1. extract to c:/b/fastboot (for example)
  2. open c:/b/fastboot/py_cmd.exe
  3. connect phone to windows via usb

on phone:

  1. settings>About phone>tap build nr or build model near bottom 7 times>that unlocks the developer options.
  2. Settings> developer options>Enable adb debugging
  3. in ADB on windows: type:

adb devices

to see which ones are available.

  1. If it says ... unauthorized, unlock phone screen and accept the pc key.

  2. then if you paste an .apk in c:/b/fastboot/test.apk, the following command installs the app:

    adb install test.apk

  3. The following command installs all the apks in a folder:

    for %f in (C:\your_app_path\*.apk) do adb install "%f"

  4. Note if you have a space in the path you should put the path between quotation marks:

    for %f in ("c:/b/fastboot/subfolder with space in the name/apks\*.apk") do adb install "%f"

a.t.
  • 2,002
  • 3
  • 26
  • 66