AAB File: Everything A Developer Need To Know About
Published: 2022-08-16 02:54:28

Traditionally, developers upload APK files directly to Google Play for distribution. However, with the release of the new Android App Bundle format (AAB), Google advises developers to use Android Studio 3.2 or later versions to convert to the new format. AAB introduced the Dynamic Delivery feature, which automatically produces APK files once an AAB file is published to the Google Play Console.


## What is an AAB file?
Google released the AAB as part of its attempts to minimize the size of Android apps. The AAB file includes the app's entire programme code. When the app is coded completely, the developer uploads it to the Google Play Store in AAB format. It contains just the parts of the programme that each device needs to execute. Google Play uses AAB to build optimal APK files for various device setups depending on DRI, CPU architecture, and languages.

AAB then distributes these to various users based on what works best for each device, a process known as Dynamic Delivery. The app download sizes will be greatly decreased using Dynamic Delivery. App bundles cannot be installed on user devices like APKs. They are instead intended to be used to generate APK files for specific device settings. 

A programme called **bundletool** can be used to produce APK files from an AAB file. Google provides this application so that developers may test app bundles on local devices before submitting them to Google Play.

## What is the difference between AAB and APK?

App Bundles are a publishing format, whereas APK (Android application package) is the packaging format that is ultimately installed on the device.

**1. AAB files are custom-made for your device**

Resources in an app are everything that isn't computer code, such as graphics, language files, or music. When you click the "Install" button for an app in the Play Store, Google will give you an APK file customised from the AAB file for your device.

Example: If the smartphone's resolution supports only Full HD, then it will get an APK without 4K content. If English and German are chosen as device languages, then the French language pack is ignored.

**2. Google signing instead of the developer signing**

Another significant difference is the way the apps are signed. Previously, the creator of an app was always the one who signed it with their developer key. When installing the app on a smartphone, this key can be used to determine whether it has been compromised.

Now, Google will sign the APKs rather than the developer, specifically when producing APK files from AABs. Logically, the keys will be kept by Google rather than the developers.

**3. Smaller file sizes than APKs**

The APKs generated through the AAB manner are smaller compared to the native APK. On average, you should be able to see a 35% reduction in this method. That doesn't sound like much at first glance, but when one includes the numerous updates for apps, it could add up at some point.

**4. AAB offers better protection for apps**

Another benefit that developers will find useful would be increased security. It will probably be more difficult to modify apps in the future, and the mod creation team might not be very happy about that. Who knows, maybe this will reduce the number of cheaters in your favourite game.


## How to Create an Android App Bundle?


There are two methods to create an AAB file

- Command Line Method 
- Android Studio Method


**Command Line Method:**
1.Open the command prompt and, using the command below, perform the bundle tasks.
`./gradlew bundleRelease`

2. Find your bundle in the build directory of your application. App/buildoutputs/bundle/release is the default destination. The command jarsigner must be used to sign this package.        
`jarsigner -keystore $pathToKeystore app-release.aab $keyAlias`

3. Replace the keyStore and keyAlias variables with the Keystore and password's actual values. The package will be signed and ready to be uploaded to Google Play.

**Android Studio Method:**
1. To get started, go to Android Studio → Build -> Generate a Signed Bundle.
2. On the pop-up menu, choose Android App Bundle and then Next.
3. Enter the KeyStore path or the location where the KeyStore is saved and Create a new KeyStore.
4. Choose a release mode from the drop-down menu and click Finish.

Now, a signed app bundle is ready. There will be an .aab file in the destination folder. This is the target Bundle file, which can now be uploaded to the Play Store and published.

## How to Open AAB File? 

To open an AAB file, you'll need software like Authorware. You'll get a Windows message asking "How do you wish to open this file?" if you don't have the right software". If you're having trouble opening your AAB file, try right-clicking or long-pressing it. Then select a programme from the "Open with" drop-down menu. 

You can also view an AAB file directly using this link. Simply drag and drop the file into this browser window. It can also be opened with bundletool and android studio.

Prerequisites for testing the AAB file using bundletool:

- A test device (Android)
- Unzipping software, such as WinRAR
- Bundletool


The following are the steps required to test the AAB file using Bundletool

1. Download bundletool by clicking this here

2. From your app bundle file, create an APK Set archive (.apks). Use the following command to produce an APK set for all device configurations supported by your app. 

   Note: Both your app bundle file and bundletool must be in the same directory for the below command to work:
             
  `java -jar "bundletool-all-1.10.0.jar" build-apks --bundle="app-release.aab" --output="app.apks"`

The.apks file will be produced in the same folder.

3. Check the .apks file's content by converting it to a zip file and then extracting its contents with WinRAR.

4. Bundletool can now deploy the right combination of APKs to a connected device from a group of APKs generated.

## How to install it?
Install .aab Files Using App Bundle Installer:

1. Install App Bundle Installer and go to the home screen and choose "Select AAB." When the next screen displays, select your .aab file by tapping the "Select AAB File" button.
2. Select the .aab file with your preferred Android file manager, then hit the "Install File" option in the app to begin the installation procedure.
3. The app will now display a pop-up explaining how it works. It uploads the .aab file, changes it to.apk format, signs it, and downloads it to your device.
4. The app installation prompt will appear once the.apk file is ready. Tap "Install" to begin the installation process, and then "Open" to begin using the app.

## How to Decompile the AAB File?
... click to view the [original post](https://www.appflow.ai/blog/aab-file?page=2) at Appflow.ai.