[Android Development] Make Bundletool Portable

Thế Dũng
3 min readJun 24, 2023

Google have required developer to publish their app to play store with Android App Bundle since August, 2021. But for the exist apps which had been uploaded before that time with apk format can be continued deliver to play store with apk. But 2023 is the deadline for using aab instead of apk.

So I have written some scripts with a .sh file to make the use of bundle tool more easier and quicker. You can find it here on my Github repository. What I mean here is you can you this tool in any machine, no need to be setup with JAVA_HOME or adb platformtools.

Before the use

With windows user, because it’s cmd or powershell can not run the .sh command line. So you need to install something to read shell script file. In my case, I recommend using git bash.

Usage

Now, you can clone this repository and run the bellow command to start using bundle tool with no extra step:

Change the permission of the .sh file as executable, allowing it to be run as a program

chmod +x installation.sh

run the installation.sh file:

./installation.sh

The installation process is separated for diffrent platforms. I have written a condition to switch between linux/mac/windows inside the installation file. You can open it to see what inside.

After the installation process is completed, you can go to the bundletool-script folder to start using with genApks.sh file:

Again, this .sh file should be allowed to be run as a program

chmod +x genApks.sh

then

./genApks.sh

After run the ./genApks.sh command, you can drag the .aab or .apks file into the terminal.

If you don’t know what is the .apks file format, it just a set of apk file that needed for your device to select to run, depended on your device’s spec. It’s the result of extracting aab file.

After hit enter, the extracting process starts. And the result is:

  • input is aab: Extract and a .apks
  • The apks file saved in the same directory with aab.
  • Start searching for any device that was connected with the pc/laptop.
  • If no device found, the process finish.
  • If 1 device was found, it will automatically install the app into the device.
  • If more than 1 device, you can select to install the app on all devices or select 1 of them by input the index of the list devices.

Another process using in here can be run if you want everything is automatic without enter anything after running the ./genApks.sh. you can pass the parameter -a or — auto like this:

./genApks.sh -a
#or
./genApks.sh --auto

This process will install the app into all of your connected devices.

Next

If you want to custom the installation apk process like allocate the keystore, setup keysign or anything to your app, then genApks.sh is the file that you need to edit.

Thanks for reading! See you in another post.

--

--