284

I built my project using the new Android App Bundle format. With APK files, I can download the APK to my device, open it, and immediately install the app. I downloaded my app as a bundle (.aab format) and my Nexus 5X running Android 8.1 can't open the file. Is there any way to install AABs on devices in the same convenient manner as APKs?

prfarlow
  • 3,624
  • 2
  • 15
  • 24
  • 2
    Looks like it takes a few more steps than a simple apk: https://developer.android.com/guide/app-bundle/test. – Mike M. May 18 '18 at 21:25
  • 1
    For future reference: https://stackoverflow.com/questions/53040047/generate-apk-file-from-aab-file-android-app-bundle – Henry Woody Jun 29 '22 at 01:40

14 Answers14

241

Short answer:

Not directly.

Longer answer:

Android App Bundles is the default publishing format for apps on the Google Play Store. But Android devices require .apk files to install applications.

The Play Store or any other source that you're installing from will extract apks from the bundle, sign each one and then install them specific to the target device.

The conversion from .aab to .apk is done via bundletool.

You can use Internal App Sharing to upload a debuggable build of your app to the Play Store and share it with testers.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
  • Under which case would we use the Build bundle(s) option, not the signed bundle considering we cant publish debug apps on the play-store – Oush Oct 06 '18 at 18:21
  • I'd mainly do that for local testing. – Ben Weiss Oct 08 '18 at 09:53
  • 8
    Release (instead of source files) of bundletool is here: https://github.com/google/bundletool/releases – Kari Jul 19 '19 at 10:26
  • Currently it is wrong answer, see other answers to create `apks` file. – CoolMind Aug 16 '19 at 10:54
  • No longer the wrong answer; now includes mention of bundletool. However, doesn't give details of use, so may still be worth seeing other answers. There is also [Kartikeya's answer](https://stackoverflow.com/a/62166750/199364) how to deploy from Android Studio. – ToolmakerSteve Jun 13 '20 at 22:24
  • Internal App Sharing has been in "Pending publication" for a day and not finished for my app. Please don't tell me it goes through the same exact scrutiny process as per the production app? @keyboardsurfer – ericn Aug 04 '20 at 14:27
  • 1
    @ericn The initial "publication" of an app is going through the usual process. Any Internal App Sharing you're doing afterwards should not be blocked by reviews. – Ben Weiss Aug 05 '20 at 15:33
  • @keyboardsurfer I think that even that initial vetting for Internal Testing is unnecessary but it's good to know the fact that this is how things work currently. Thanks – ericn Aug 05 '20 at 15:45
  • 1
    For reference, [this](https://beebom.com/how-install-android-app-bundles/) page explain alternative app options to install AAB files. – not2qubit Aug 09 '21 at 18:16
115

For MAC:

brew install bundletool
bundletool build-apks --bundle=app-release.aab --output=app-release.apks
bundletool install-apks --apks=app-release.apks
Martin Braun
  • 10,906
  • 9
  • 64
  • 105
Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78
  • after the third command terminal showed a path for the app, but the folder is not available – Furquan Jun 05 '20 at 13:41
  • 2
    @Furquan, that path displayed is the path in your connected device. The command installs the apk to your device. – Bijoy Thangaraj Aug 18 '20 at 13:46
  • Unfortunately, macOS Catalina or newer is required for this software. – Elad Nava Jul 13 '22 at 07:05
  • 7
    installing bundletool required something around 2 Gbs of dependencies... – Alberto M Feb 22 '23 at 05:51
  • @Furquan I think it immediately deletes the file as it's temporary as soon as the APK is installed on the device. you don't have to manually adb install after install-apks command – eden Jun 26 '23 at 07:22
85

Installing the aab directly from the device, I couldn't find a way for that.

But there is a way to install it through your command line using the following documentation You can install apk to a device through BundleTool

According to "@Albert Vila Calvo" comment he noted that to install bundletools using HomeBrew use brew install bundletool

You can now install extract apks from aab file and install it to a device

Extracting apk files from through the next command

java -jar bundletool-all-0.3.3.jar build-apks --bundle=bundle.aab --output=app.apks --ks=my-release-key.keystore --ks-key-alias=alias --ks-pass=pass:password

Arguments:

  • --bundle -> Android Bundle .aab file
  • --output -> Destination and file name for the generated apk file
  • --ks -> Keystore file used to generate the Android Bundle
  • --ks-key-alias -> Alias for keystore file
  • --ks-pass -> Password for Alias file (Please note the 'pass' prefix before password value)

Then you will have a file with extension .apks So now you need to install it to a device

java -jar bundletool-all-0.6.0.jar install-apks --adb=/android-sdk/platform-tools/adb --apks=app.apks

Arguments:

  • --adb -> Path to adb file
  • --apks -> Apks file need to be installed
Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Omar HossamEldin
  • 3,033
  • 1
  • 25
  • 51
  • 37
    If you use Mac you can install Bundletool with Homebrew: `brew install bundletool`. Then just run the commands like this: `bundletool build-apks --bundle=./app/release/app.aab --output=./app/release/app.apks` – Albert Vila Calvo Apr 04 '19 at 08:52
  • 3
    --ks-pass=pass:password specifies the password for the keystore. To specify the password for the keyfile use --key-pass=pass:password – jwitt98 May 02 '19 at 17:03
  • I'm facing the same issue, I followed the steps that you described, however, when the app is installed in my android device, I can't open it ( it opens the closes automatically) – aName Jul 21 '19 at 18:55
  • Thanks! `--key-pass=pass:`... is required, but strangely a password is incorrect, so I have to type it manually. After `... install-apks --adb=...` it writes: 'The APKs have been extracted in the directory:...', but that folder doesn't exist, and it doesn't install on device. – CoolMind Aug 16 '19 at 10:52
  • 1
    EXAMPLE: `C:\Users\Aterr\Desktop\hack>java -jar "C:\Users\Aterr\Desktop\hack\bundletool-all-0.10.3.jar" install-apks --adb="C:\Users\Aterr\AppData\Local\Android\Sdk\platform-tools\adb.exe" --apks="C:\Users\Aterr\Desktop\hack\extractedapks.apks"` – Choletski Oct 25 '19 at 07:48
  • If you're fine with a debug build, you can skip all of the key/keystore flags and bundletool will use your system's debug certificate. – amram99 Aug 23 '21 at 13:38
41

You cannot install app bundle [NAME].aab directly to android device because it is publishing format, but there is way to extract the required apk from bundle and install it to you device, the process is as follow

  1. Download bundletool from here
  2. run this in your terminal,
java -jar bundletool.jar build-apks --bundle=bundleapp.aab --output=out_bundle_archive_set.apks
  1. Last step will generate a file named as out_bundle_archive_set.apks, just rename it to out_bundle_archive_set.zip and extract the zip file, jump into the folder out_bundle_archive_set > standalones, where you will seee a list of all the apks

There goes the reference from android developers for bundle tools link

android developer reference

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
Ali Tamoor
  • 896
  • 12
  • 18
  • It requires a signing key and passwords, see https://stackoverflow.com/a/52704544/2914140 and https://developer.android.com/studio/command-line/bundletool. – CoolMind Aug 16 '19 at 07:59
  • @CoolMind the signing key and passwords are when you want to build the set of signed apk out of bundle, and want to deploy apk on the device, check the updated answer – Ali Tamoor Aug 29 '19 at 09:31
  • 8
    there is no folder nammed standalones, instead there is nammed splits – Gopal Singh Sirvi Jul 18 '20 at 12:45
39

If you want to install apk from your aab to your device for testing purpose then you need to edit the configuration before running it on the connected device.

  1. Go to Edit Configurations
    enter image description here
  2. Select the Deploy dropdown and change it from "Default apk" to "APK from app bundle".enter image description here
  3. Apply the changes and then run it on the device connected. Build time will increase after making this change.

This will install an apk directly on the device connected from the aab.

Kartikeya_M
  • 551
  • 6
  • 7
  • 4
    This helped me to replicate one bug which appears only on release build. Turns out the bug is appearing when installed from AAB. Thanks a lot. – Cerlin Jun 12 '20 at 16:13
  • Just to clarify, I assume the instructions and screenshots are from Android Studio? [I'm using Xamarin, not using Android Studio. I realize most developers are using Android Studio.] – ToolmakerSteve Jun 13 '20 at 22:18
  • Yes, the instructions and screenshots are from android studio 3.6.3. – Kartikeya_M Jun 15 '20 at 05:20
  • Thank you, fixing the bug with localizations with this approach https://developer.android.com/guide/app-bundle/configure-base#disable_config_apks – Sergey Chilingaryan Dec 07 '21 at 15:18
  • Can I use Android Studio to install an existing .aab file build I see the WiFi connected device and I specified a configuration however it says no "module" specified? I don't know where I tell it to use my existing .aab (from a ionic/cordova framework build). – Meryan May 07 '22 at 09:13
27

For those, who want single universal.apk that can run on every android device:

brew install bundletool
bundletool build-apks --mode universal --bundle ./app-release.aab --output ./app.apks
mv app.apks app.zip
unzip app.zip

Now, you can get your universal.apk

whalemare
  • 1,107
  • 1
  • 13
  • 30
7

This worked for me on a mac. You need to use a tool called bundletool You can install it incase if not already installed using brew

brew install bundletool

Run this command to extract and store the apks file at the desired location

bundletool build-apks --bundle=path/to/app-release.aab --output=/path/to/output/app.apks --local-testing

Install on a connected Android device

bundletool install-apks --apks=/path/to/output/app.apks

I have noted the complete command with output in a gist here https://gist.github.com/maheshmnj/6f5debbfae2b8183d94ca789d081f026

Mahesh Jamdade
  • 17,235
  • 8
  • 110
  • 131
2

If you're using Maui at this point Visual Studio 2022 only creates AAB files; however, you can create an APK from a command line.

Change directory to where your project is located and run this:

dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=blah
D. Kermott
  • 1,613
  • 17
  • 24
2

To convert aab ro apk follow this simple steps:

1.Download bundltool-all-1.14.1.jar from this link

2.Move [your-aab-file-name].aab and bundletool-all-1.14.1.jar to a Desktop.

3.Open Terminal and write this code cd .\Desktop\ and press enter.{This will take you to the desktop}

4.Now write this code and press enter:

C:\Users\[Your-user-name]\Desktop\bundletool-all-1.14.1.jar build-apks --bundle=[Your-aab-file-name.aab] --output=app-release.aab.apks --mode=universal

5.After that you have a file named "app-release.aab.apks" on your Desktop, open it with WinRAR {or something like that} and you have apk file, and you can install it.

1

For Windows 11:

PS C:/folder-with-aab-file> java -jar C:\dev\bundletool-all-1.9.1\bundletool.jar build-apks --bundle=app-release.aab --output=app-release.aab.apks --mode=universal

PS C:/folder-with-aab-file> ren app-release.aab.apks app-release.aab.apks.zip

After descompact zip file, the apk file'll with the name: universal.apk

0

If you want to install the APP bundle without using PLAY STORE, You need to change your build variant to "release" at Android studio.

If you cannot build App yourself but have a release bundle, then refer to the most popular answer.

Go to Android Studio > Build > Select Build Variant..

enter image description here

Once you do this your build configuration may start showing errors. This is because you now need to provide signing details in this configuration as well (this refers signing details from build.gradle)

enter image description here

you may either Edit the configuration and go to the Fix button at the bottom which will ask you to fill in signing details.

Or you may edit the build.gradle Make sure you provide buildTypes {} and signingConfigs {}

android {
    signingConfigs {
        release {
            storeFile file('<Your PATH>\\keystore.jks')
            storePassword 'XXXXX
            keyAlias 'XXXXX'
            keyPassword 'xxxxx'
        }
        debug {
           storeFile file('<Your PATH>\\keystore.jks')
            storePassword 'XXXXX
            keyAlias 'XXXXX'
            keyPassword 'xxxxx'
        }
    }
    compileSdkVersion 32
    defaultConfig {
       ....
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug
        {
            signingConfig signingConfigs.debug
        }
    }
    ...


}

dependencies {

    ...
}

There is one or two minutes of delay before Android Studio starts reflecting correctly. Otherwise, you may do a clean rebuild and then run the app.

When you run the app this time it will be installed in release mode on the target device. You may need a way to identify the Build Variant of the installed app. You may show the build name and variant somewhere in your app. Or if you have a button somewhere which shows only in debug mode you can check that.

Sandeep Dixit
  • 799
  • 7
  • 12
0

If you have the project you can just build an app with android studio or push it directly to the device if you run a debug or release config with the device connected and selected as the target so long as you enable adb in developer mode on the device and tap trust this computer when you connect it to your machine.

But if you have the bundle because you're trying to install an app pulled from one phone onto another, there are free online services that convert play store links into a direct download of the apk. Just turn on add debugging on the device and adb install <path-to-apk> from the terminal.

If you have more than one device connected with adb enabled you can adb devices to get a list of their identifiers and adb install <path-to-apk> <device-id> will work as well. Or you can use adb to your advantage and do many things on multiple devices at once depending on your needs. There's even ways to adb over wifi.

You will need adb from the android-sdk tools to do any of this though, with Android Studio installed you would have a local installation already but it may not be in your path. However studios terminal likely has access to it since it would be the sdk path your IDE has saved in preferences.. If not you can download a standalone sdk/find out which one studio is using from it's preferences and either

  • Add adb from the platform-tools directory of said sdk it to your path (best)
  • Invoke adb from it's absolute path you just located and just keep hitting up to re-use your last command, swapping out the apk/device
  • cd to the adb directory and just use it with the full path to each of your apks (easiest)
theZ3r0CooL
  • 147
  • 2
  • 10
-1

Is there any way to install AABs on devices in the same convenient manner as APKs?

As installing is done by third party apps or mobile company file manager like apps.
The upcoming file managers versions, hence forth, will come with "aab" managing tools.

I searched "android aab installer" on playstore and found one.

enter image description here

deliberately not naming it.
The one I installed, extracted the bundle online,
But after that this app wasn't able to install this extracted app by itself (on my mi [miui] device ).
But this application saved the online extracted apk on phone memory, from where I was able to install it.
remember:
Google's "files" application wasn't able to install this apk
but
my system (in built) filer manager was able to.

sifr_dot_in
  • 3,153
  • 2
  • 33
  • 42
-3

Use (on Linux): cd android ./gradlew assemblyRelease|assemblyDebug

An unsigned APK is generated for each case (for debug or testing)

NOTE: On Windows, replace gradle executable for gradlew.bat

  • yes this is true actually true, but argument name is assembleDebug. For a very simple app It works, but going beyond for more device resources, it appears it is compiled with too much dependencies from the development host. – Matteus Barbosa Jan 30 '23 at 00:50