ChatGPT解决这个技术问题 Extra ChatGPT

Install Android App Bundle on device

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?

Looks like it takes a few more steps than a simple apk: developer.android.com/guide/app-bundle/test.

k
keyboardsurfer

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.


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
I'd mainly do that for local testing.
Release (instead of source files) of bundletool is here: github.com/google/bundletool/releases
@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.
For reference, this page explain alternative app options to install AAB files.
S
Shashank Agrawal

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


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
--ks-pass=pass:password specifies the password for the keystore. To specify the password for the keyfile use --key-pass=pass:password
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)
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.
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"
E
Erti-Chris Eelmaa

For MAC:

brew install bundletool
bundletool build-apks --bundle=./app.aab --output=./app.apks
bundletool install-apks --apks=app.apks

after the third command terminal showed a path for the app, but the folder is not available
@Furquan, that path displayed is the path in your connected device. The command installs the apk to your device.
Unfortunately, macOS Catalina or newer is required for this software.
T
ToolmakerSteve

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

Download bundletool from here run this in your terminal,

java -jar bundletool.jar build-apks --bundle=bundleapp.aab --output=out_bundle_archive_set.apks

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

https://i.stack.imgur.com/XZonY.png


@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
there is no folder nammed standalones, instead there is nammed splits
K
Kartikeya_M

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.

Go to Edit Configurations Select the Deploy dropdown and change it from "Default apk" to "APK from app bundle". 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.


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.
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.]
Yes, the instructions and screenshots are from android studio 3.6.3.
Thank you, fixing the bug with localizations with this approach developer.android.com/guide/app-bundle/…
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).
w
whalemare

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


nice, but, the question is "is there any way to install AABs on devices in the same convenient manner as APKs?"
loved it, better than the one mentioning standalone/split directory
M
Mahesh Jamdade

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


S
Sandeep Dixit

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..

https://i.stack.imgur.com/YIm4E.png

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)

https://i.stack.imgur.com/XQbBZ.png

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.


s
sifr_dot_in

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.

https://i.stack.imgur.com/lqKbp.png


E
Eddie Ruiz

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