128

Although the docs mentioned

If you haven't already done so, download bundletool from the GitHub repository.

However, the repo contains only a jar file. How do I install it so that I can run with the 'bundletool' command just like the docs' example?

auspicious99
  • 3,902
  • 1
  • 44
  • 58
Vincent Paing
  • 2,308
  • 3
  • 17
  • 29
  • 22
    meanwhile you can run it using `java -jar bundletool-all-0.6.2.jar` – Tim Nov 14 '18 at 11:23
  • 6
    I wonder how many people came here from https://github.com/google/bundletool/releases - how hard would it be to add an install/use section to the repo – mekdigital Sep 29 '22 at 23:53

8 Answers8

164

If you have brew installed simply run brew install bundletool and the alias will be set up for you as well. It did the trick for me.

flarkmarup
  • 5,129
  • 3
  • 24
  • 25
76

You can create an alias (or doskey on Windows), e.g.

alias bundletool='java -jar bundletool-all.jar'

Pierre
  • 15,865
  • 4
  • 36
  • 50
  • I thought it was a command line tool you could install as first. This is what I did in my terminal right now. Thanks – Vincent Paing Nov 15 '18 at 15:30
  • Is this an exact command in Windows command line? 'alias' is not recognized as an internal or external command, operable program or batch file. – Yar Apr 17 '20 at 05:24
  • 1
    As mentioned in the parenthesis, it's called doskey on Windows. – Pierre Apr 17 '20 at 13:56
  • 1
    I am on linux and I have jdk8 installed, this shows `Error: Unable to access jarfile bundletool.jar` – Dimitri Kopriwa Aug 10 '21 at 14:15
  • I just typed in cmd: doskey bundletool=java -jar C:\Users\user\bundletool-all-1.14.0.jar $* And then bundletool worked for me – Ricardo Araque Apr 12 '23 at 22:10
42

Another alternative is access Bundletool release page and download the bundletool-all-[LAST-VERSION].jar file into some directory.

After that you could run it on the directory calling:

java -jar bundletool-all-0.10.2.jar your_arguments_here

If you want, rename the jar file to bundletool.jar, then run it calling:

java -jar bundletool.jar your_arguments_here

If you don't want call java every time, you can create an alias for that, and after that run quicly:

alias bundletool='java -jar bundletool-all.jar'

bundletool your_arguments_here
Tiago Gouvêa
  • 15,036
  • 4
  • 75
  • 81
19

On a mac, it can be easily done using homebrew

brew install bundletool

then you can run commands like this

bundletool install-apks --apks=release.apks

you can use the command below to generate apks

bundletool build-apks --bundle=aab_path.aab --output=release.apks

The above command generates apks file which can later be extracted to give various apk files.

auspicious99
  • 3,902
  • 1
  • 44
  • 58
Tushar Saha
  • 1,978
  • 24
  • 29
15

To make shortcut/alias in Windows 10, in cmd run:

@doskey bundletool=java -jar <youPath>\bundletool-all.jar $*

You must be already added Java folder path to system environment variables or just google it.

Gg M
  • 386
  • 3
  • 6
3

Apparently for Linux you have to download the jar from: https://github.com/google/bundletool/releases

and then run java -jar <PATH_TO_JAR> ...

to simplify things you can add in /usr/local/bin/ a bundletool script

#!/usr/bin/env zsh
exec java -jar "$HOME/path/to/jar" "$@"

and sudo chmod +x /usr/local/bin/bundletool

Now you can run bundletool from wherever you want

J.Stange
  • 478
  • 3
  • 8
1

As for me, on windows, I just set assoc and ftype so that .jar will open with java -jar

First I download bundletool.someversion.jar into some folder under PATH env (so that it would exposed)

Open cmd as admin and link .jar to jarfile with cmd assoc .jar=jarfile (actually can be any name, make it jarfile is just convention in the same way as other file)

Then ftype jarfile=^%JAVA_HOME^%\bin\java.exe -jar %1 %~2

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftype

Then we could execute bundletool.someversion.jar or any jar to open it as java directly

Thaina Yu
  • 1,372
  • 2
  • 16
  • 27
0

You don't need to have

brew.

Install it somewhere, but not in your project directory
npm install bundletool