Git Product home page Git Product logo

bundletool's Introduction

bundletool

Bundletool is a tool to manipulate Android App Bundles and Android SDK Bundles.

The Android App Bundle is a format for publishing Android apps in app distribution stores such as Google Play.

The Android SDK Bundle is a format for publishing runtime-enabled SDKs to SDK distribution platforms such as Google Play SDK Console.

Bundletool has a few different responsibilities:

  • Build an Android App Bundle from pre-compiled modules of a project.

  • Generate an APK Set archive containing APKs for all possible devices.

  • Extract APK(s) from the APK Set compatible with a given device.

  • Install APK(s) from the APK Set compatible with a connected device.

  • Extract device spec from a device as a JSON file.

  • Add code transparency to an Android App Bundle. Code transparency is an optional code signing mechanism.

  • Verify code transparency inside an Android App Bundle, APK files or an application installed on a connected device.

  • Build an Android SDK Bundle from a pre-compiled module of a project.

  • Generate an APK Set archive containing the SDK APKs for all devices.

  • Generate an Android SDK archive, a Maven-friendly representation of an Android SDK Bundle.

Read more about the App Bundle format and Bundletool's usage at g.co/androidappbundle

Documentation of bundletool commands can be found at: https://developer.android.com/studio/command-line/bundletool

Releases

Latest release: 1.15.6

bundletool's People

Contributors

aliscafo avatar barriosnahuel avatar dovix91 avatar eas5 avatar fooock avatar friederbluemle avatar mohammadmouadi avatar panks avatar plecesne avatar shashanksr avatar sopo-c avatar star-zero avatar tdobek avatar tutipeti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bundletool's Issues

Question: How to use this tool in Android device

Suppose I want to share/backup an app that was installed as an app-bundle.
I know how to collect the various APK files that are a part of the app-bundle (by looking at the paths of packageInfo.applicationInfo.splitPublicSourceDirs : https://developer.android.com/reference/android/content/pm/ApplicationInfo#splitPublicSourceDirs )

But is it possible to uninstall the app, and later install it using those APK files, and this library?

If so, how? Does it require a rooted device? Are the APK files all that is needed to restore the backup?

NoSuchFileException when paths contain a tilde sign (~)

Describe the bug
NoSuchFileException thrown when runs build-apks command

Bundletool version(s) affected
Version: [e.g. 0.4.1]

Stacktrace

macbook-pro:bin$ java -jar bundletool-all-0.4.1.jar build-apks  --bundle=../../app/build/outputs/bundle/playRelease/bundle.aab --output=~/Downloads/tandem.apks
WARNING: The APKs won't be signed and thus not installable unless you also pass a keystore via the flag --ks. See the command help for more information.
[BT:0.4.1] Error: Error while writing the APK Set archive to '~/Downloads/tandem.apks'.
com.android.tools.build.bundletool.exceptions.CommandExecutionException: Error while writing the APK Set archive to '~/Downloads/tandem.apks'.
        at com.android.tools.build.bundletool.exceptions.CommandExecutionException$Builder.build(CommandExecutionException.java:81)
        at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.writeTo(ApkSetBuilderFactory.java:124)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.executeWithTempDir(BuildApksCommand.java:310)
        at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:51)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:237)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:72)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)
Caused by: java.nio.file.NoSuchFileException: /var/folders/3j/8k6z66l50dq_d1sjfxl8cphh0000gn/T/ZipBuilder-3573363741609217405.zip.tmp -> ~/Downloads/tandem.apks
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:457)
        at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
        at java.nio.file.Files.move(Files.java:1395)
        at com.android.tools.build.bundletool.io.ZipBuilder.writeTo(ZipBuilder.java:105)
        at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.writeTo(ApkSetBuilderFactory.java:119)
        ... 5 more

To Reproduce

Expected behavior
Generated .apks file

Known workaround

Environment:
Mac OS

Additional context

Use adb in path by default

Describe the bug
adb must be passed to bundletool, is it possible that it could use the adb executable in my path.

Bundletool version(s) affected
Version: 0.6.0

Stacktrace
[BT:0.6.0] Error: Unable to determine the location of ADB. Please set the --adb flag or define ANDROID_HOME environment variable.

To Reproduce
Use bundletool without providing an adb

Expected behavior
It would default to the adb on my path

Environment:
OS: Linux

get-device-spec fails when parent directory is not created with an ambiguous message

Describe the bug
Error message can be more descriptive.

It says that the file store/device-specs/moto-g-5-plus.json doesn't exists but it actually fails because the device-specs directory doesn't exists. When the JSON file isn't there, bundletool creates it OK.

Bundletool version(s) affected
Version: 0.8.0

Stacktrace

[BT:0.8.0] Error: Error while writing the output file 'store/device-specs/moto-g-5-plus.json'.
java.io.UncheckedIOException: Error while writing the output file 'store/device-specs/moto-g-5-plus.json'.
        at com.android.tools.build.bundletool.commands.GetDeviceSpecCommand.writeDeviceSpecToFile(GetDeviceSpecCommand.java:173)
        at com.android.tools.build.bundletool.commands.GetDeviceSpecCommand.execute(GetDeviceSpecCommand.java:161)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:83)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:46)
Caused by: java.nio.file.NoSuchFileException: store/device-specs/moto-g-5-plus.json
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
        at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
        at java.nio.file.Files.newOutputStream(Files.java:216)
        at java.nio.file.Files.write(Files.java:3292)
        at com.android.tools.build.bundletool.commands.GetDeviceSpecCommand.writeDeviceSpecToFile(GetDeviceSpecCommand.java:170)
        ... 3 more

To Reproduce
Steps to reproduce the behavior.
Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

bundletool get-device-spec --output store/device-specs/moto-g-5-plus.json

where:

  • directory store already exists
  • directory device-specs doesn't exists
  • JSON file doesn't exists

Expected behavior
It would be awesome to create the whole directories tree. If that's not possible, then it would be great to read something like: "The specified output path is invalid. Is the parent directory of the JSON file already created?"

Known workaround
Create the parent directory manually.

Environment:
OS: Mac OS 10.13.6

libs file(*.so) inside split apk doesn't extracted to folder "lib" in App Bundle

Hello team,
I have problem when try to read libs file (.so) within app bundle.
commonly, if we install installer file (
.apk), this .apk file will be extracted in the device on folder data/app/packageName and inside it there are "lib" folder that contain libs file.
But when I installed app bundle and when bundle is extracted on the device my folder "data/app/mypackageName/lib" is empty. all my libs files (*.so) that I need still in splitApk.apk file

preview for extracted bundle file in device
bundle

preview for extracted .apk file in device
apk file

command that I used to install aps bundle is :
install-apks --apks=!BASENAME_PATH!.apks --modules=dlc_module

Question :
Could I get all libs(*.so) files such as if we use .apk file as installer? because I need this file to handle security system in my apps
If I couldn't , Could you please give me some advice?

Btw, sorry if my question is not clear enough, my english is very bad.

failed build-apks from aab with flavors

Describe the bug
I was download aab example from google samples, and add a flavordimension in it. flavor detail as below
`
android {
flavorDimensions "mode", "app"

productFlavors {

    bugcheck {
        dimension "mode"

        defaultConfig {
            targetSdkVersion 21

            ndk {
                abiFilter "armeabi-v7a"
            }

            // for lambda support.
            compileOptions {
                sourceCompatibility JavaVersion.VERSION_1_8
                targetCompatibility JavaVersion.VERSION_1_8
            }
        }
    }

    dogfood {
        dimension "mode"

        defaultConfig {
            targetSdkVersion 21

            ndk {
                abiFilter "armeabi-v7a"
            }

            // for lambda support.
            compileOptions {
                sourceCompatibility JavaVersion.VERSION_1_8
                targetCompatibility JavaVersion.VERSION_1_8
            }
        }
    }

    pro {
        minSdkVersion 14

        dimension "app"
    }

    normal {
        minSdkVersion 14

        dimension "app"
    }
}

}`

use ./gradlew clean app:bundleDogfoodProDebug to build bundle,
got a app.aab,

finally use bundletool build-apks --bundle=./app/build/outputs/bundle/bugcheckProDebug/app.aab --output=outputs.apks to extract apks
face a crash

Error: Program type already present: com.google.android.samples.dynamicfeatures.ondemand.BuildConfig [BT:0.5.1] Error: Dex merging failed. com.android.tools.build.bundletool.exceptions.CommandExecutionException: Dex merging failed. at com.android.tools.build.bundletool.mergers.D8DexMerger.translateD8Exception(D8DexMerger.java:98) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:77) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFiles(ModuleSplitsToShardMerger.java:225) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.lambda$mergeDexFilesAndCache$0(ModuleSplitsToShardMerger.java:192) at java.util.HashMap.computeIfAbsent(HashMap.java:1118) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFilesAndCache(ModuleSplitsToShardMerger.java:190) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:138) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.merge(ModuleSplitsToShardMerger.java:92) at com.android.tools.build.bundletool.splitters.BundleSharder.shardBundle(BundleSharder.java:103) at com.android.tools.build.bundletool.commands.BuildApksManager.generateStandaloneApks(BuildApksManager.java:300) at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:165) at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:52) at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:368) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:73) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:76) at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45) at com.android.tools.r8.D8.run(D8.java:67) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:70) ... 13 more Caused by: com.android.tools.r8.utils.AbortException at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:77) at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:58) at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:67) ... 16 more

Bundletool version(s) affected
Version: BundleTool 0.5.1

Expected behavior
normal get apks

Environment:
OS: [e.g. iOS 10.3.3]

location of ADB

我执行安装是出现这个错误,在Windows环境下

java -jar F:\tool\bundletool\bundletool.jar install-apks --apks=F:\tool\bundletool\app.apks
[BT:0.7.2] Error: Unable to determine the location of ADB. Please set the --adb flag or define ANDROID_HOME environment variable.
com.android.tools.build.bundletool.exceptions.CommandExecutionException: Unable to determine the location of ADB. Please set the --adb flag or define ANDROID_HOME environment variable.
        at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$null$1(InstallApksCommand.java:117)
        at java.util.Optional.orElseThrow(Unknown Source)
        at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$fromFlags$2(InstallApksCommand.java:115)
        at java.util.Optional.orElseGet(Unknown Source)
        at com.android.tools.build.bundletool.commands.InstallApksCommand.fromFlags(InstallApksCommand.java:110)
        at com.android.tools.build.bundletool.commands.InstallApksCommand.fromFlags(InstallApksCommand.java:99)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)

screenDensity supports only numbers, not 'xxxhdpi' values

Describe the bug
Documentation says it is possible to use 'xxxhdpi' values for 'screenDensity' key in device specification JSON. Currently it is impossible due to ''InvalidProtocolBufferException: Not an uint32 value: "xxxhdpi""

Bundletool version(s) affected
Version: [e.g. 0.3.3]

Stacktrace

com.android.tools.build.bundletool.exceptions.CommandExecutionException: I/O error while reading the device spec file 's9.json'.
	at com.android.tools.build.bundletool.exceptions.CommandExecutionException$Builder.build(CommandExecutionException.java:81)
	at com.android.tools.build.bundletool.commands.ExtractApksCommand.parseDeviceSpec(ExtractApksCommand.java:119)
	at com.android.tools.build.bundletool.commands.ExtractApksCommand.fromFlags(ExtractApksCommand.java:95)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:75)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Not an uint32 value: "xxxhdpi"
	at com.google.protobuf.util.JsonFormat$ParserImpl.parseUint32(JsonFormat.java:1590)
	at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:1761)
	at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1483)
	at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1315)
	at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1273)
	at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1135)
	at com.google.protobuf.util.JsonFormat$Parser.merge(JsonFormat.java:351)
	at com.android.tools.build.bundletool.commands.ExtractApksCommand.parseDeviceSpec(ExtractApksCommand.java:113)

To Reproduce
Steps to reproduce the behavior.

{
  "supportedAbis": ["arm64-v8a", "armeabi-v7a"],
  "supportedLocales": ["en", "fr"],
  "screenDensity": xxxhdpi,
  "sdkVersion": 27
}

  • run java -jar bundletool-all-0.3.3.jar extract-apks --apks=app.apks --device-spec=device.json --output-dir=apks

Environment:
OS: [Mac OS 10.13.4]

Installation of the app failed

Describe the bug
When execute the install comand,for example:
java -jar bundletoo.jar install-apks --apks=test.apks --device-id LHTDU16927053257

In effect,the app install success,but Tip me “Error: Installation of the app failed.” on the console。
I can find the app package for the device。

Bundletool version(s) affected
Version: [release 0.7.1]

Stacktrace
The APKs have been extracted in the directory: /tmp/temp644958597244074835
[BT:0.7.1] Error: Installation of the app failed.
com.android.tools.build.bundletool.exceptions.InstallationException: Installation of the app failed.
at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:47)
at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:41)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:122)
at com.android.tools.build.bundletool.device.ApksInstaller.installOnDevice(ApksInstaller.java:94)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:82)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:62)
at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$3(InstallApksCommand.java:166)
at com.android.tools.build.bundletool.io.TempFiles.lambda$withTempDirectory$0(TempFiles.java:68)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:52)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectory(TempFiles.java:71)
at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:146)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)
Caused by: com.android.ddmlib.InstallException
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:100)
at com.android.ddmlib.Device.installPackages(Device.java:928)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:106)
... 10 more
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:557)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:383)
at com.android.ddmlib.Device.executeShellCommand(Device.java:575)
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:86)
... 12 more

Unable to use bundletool.

Describe the bug
After downloading the latest bundletool version (0.8.0) I'm unable to use it as show below:

screen shot 2019-02-26 at 23 15 44

Bundletool version(s) affected
Version: 0.8.0

To Reproduce
Just download the .jar file from the release page to get that error.

Expected behavior
bundletool should be launched.

Environment:
OS: MacOS 10.14.3

Support downgrading APKs

Is your feature request related to a problem? Please describe.

It would be nice to have the option to downgrade APKs on debuggable devices (i.e., install an older versionCode than what is currently installed). Specifically, this should match adb install -d behavior.

Describe the solution you'd like

I think it's fine to pass -d on user, userdebug, eng devices, I think package manager will simply ignore the request to downgrade if the device is not debuggable. This is how adb install -d seems to work.

Describe alternatives you've considered

The alternative is for our script to first uninstall the on-device APK, and to then install the new APK. This poses some issues: what if the uninstall succeeds but the install fails for some unexpected reason? The device is now in a worse state than before, when the preferred outcome would be to leave the original APK on the device.

We currently perform this workaround for user devices, but it would be nice to avoid it whenever possible, and I think there's value in matching adb install's features whenever possible.

How to preset some custom languages in the base-master apk?

Is your feature request related to a problem? Please describe.
Some language for example jp zh , how to preset the jp and zh language in the base-master.apk,
because the two language is used by default in some areas.

Describe the solution you'd like
Bundletool can support the func .

Describe alternatives you've considered
it maybe modify the languagesplitter.java

Additional context
Add any other context or screenshots about the feature request here.

bundletool build-apks has no dex files

Describe the bug
When I used the bundletool build-apks
show the next error.
I need to use a custom Application. Any idea to fix it?

[BT:0.7.1] Error: Module 'base' has no dex files but the attribute 'hasCode' is not set to false in the AndroidManifest.xml.
com.android.tools.build.bundletool.exceptions.ValidationException: Module 'base' has no dex files but the attribute 'hasCode' is not set to false in the AndroidManifest.xml.
at com.android.tools.build.bundletool.exceptions.ValidationException$Builder.build(ValidationException.java:49)
at com.android.tools.build.bundletool.exceptions.ValidationException$Builder.build(ValidationException.java:41)
at com.android.tools.build.bundletool.validation.DexFilesValidator.validateHasCode(DexFilesValidator.java:86)
at com.android.tools.build.bundletool.validation.DexFilesValidator.validateModule(DexFilesValidator.java:58)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:78)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleUsingSubValidator(ValidatorRunner.java:69)
at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundle$3(ValidatorRunner.java:58)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundle(ValidatorRunner.java:58)
at com.android.tools.build.bundletool.validation.AppBundleValidator.validate(AppBundleValidator.java:73)
at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:103)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:52)
at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:399)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:77)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)

Bundletool version(s) affected
Version: [e.g. 0.7.1]

To Reproduce
Steps to reproduce the behavior.
bundletool build-apks --bundle=/xx/xx --output=/xx/xx --ks=key.keystore --ks-pass=pass:password--ks-key-alias=xxx --key-pass=pass:password

Bundle tool "install apks" command isn't working sometimes.

Describe the bug
Bundle tool install apks command isn't working bundletool install-apks --apks=my_app.apks on Nexus 6P device (Android Oreo) sometimes. Although it doesn't give any problem for Google Pixel 2 XL.

I tried to run the following the command to get the device specs. but got the following weird output. Do you know what could be the cause of this?

$ bundletool get-device-spec --output=nexus6p.json
Warning: Can't detect device locale, will use 'en-US'.

$ cat nexus6p.json
{
  "supportedLocales": ["en-US"],
  "screenDensity": 4294967295,
  "sdkVersion": 1
}%

Bundletool version(s) affected
Version: [e.g. 0.3.3]

Stacktrace
$ bundletool install-apks --apks=my_app.apks

Warning: Can't detect device locale, will use 'en-US'.
[BT:0.3.3] Error: Installation of the app failed.
com.android.tools.build.bundletool.exceptions.InstallationException: Installation of the app failed.
at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:47)
at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:41)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:98)
at com.android.tools.build.bundletool.device.ApksInstaller.installOnDevice(ApksInstaller.java:89)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:78)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:45)
at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$4(InstallApksCommand.java:138)
at com.android.tools.build.bundletool.io.TempFiles.lambda$withTempDirectory$0(TempFiles.java:67)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:51)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectory(TempFiles.java:70)
at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:122)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:85)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)
Caused by: com.android.ddmlib.InstallException: List of APKs is empty: the main APK must be specified.
at com.android.ddmlib.Device.installPackages(Device.java:930)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:92)
... 10 more
Caused by: java.lang.IllegalArgumentException: List of APKs is empty: the main APK must be specified.
at com.android.ddmlib.SplitApkInstaller.validateArguments(SplitApkInstaller.java:214)
at com.android.ddmlib.SplitApkInstaller.create(SplitApkInstaller.java:237)
at com.android.ddmlib.Device.installPackages(Device.java:925)

To Reproduce
Steps to reproduce the behavior.

  • Generate the apks set archive.
  • install the apk from this apks set.

Environment:
OS: MAC OS
Device : Nexus 6p

Gradle task to generate bundle and universal apk

Is your feature request related to a problem? Please describe.
Our Daily CI builds and outputs APKs to S3 bucket and QA/Engineers use this build for testing, but now with Android App Bundles we need to build, then using bundletool.jar to generate universal APK, and push APK to S3 bucket.

Describe the solution you'd like
It will be nice if the Gradle task $./gradlew bundleRelease generated the bundle *.aab and the universal.apk

Describe alternatives you've considered
Creating a custom Gradle task to generate universal apk from bundle.

Bundle tool "install apks" command isn't working

Describe the bug
Bundle tool install apks command isn't working bundletool install-apks --apks=my_app.apks

Bundletool version(s) affected
Version: [e.g. 0.3.3]

Stacktrace
11:03:02 E/SplitApkInstaller: Failed to finalize session : INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl1034936521.tmp/0_universal has no certificates at entry AndroidManifest.xml [BT:0.3.3] Error: Installation of the app failed. com.android.tools.build.bundletool.exceptions.InstallationException: Installation of the app failed. at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:47) at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:41) at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:98) at com.android.tools.build.bundletool.device.ApksInstaller.installOnDevice(ApksInstaller.java:89) at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:78) at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:45) at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$4(InstallApksCommand.java:138) at com.android.tools.build.bundletool.io.TempFiles.lambda$withTempDirectory$0(TempFiles.java:67) at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:51) at com.android.tools.build.bundletool.io.TempFiles.withTempDirectory(TempFiles.java:70) at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:122) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:85) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44) Caused by: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl1034936521.tmp/0_universal has no certificates at entry AndroidManifest.xml at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:91) at com.android.ddmlib.Device.installPackages(Device.java:926) at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:92) ... 10 more

To Reproduce

  • Generate the andorid app bundle
  • Generate apk archive set
  • Try to install the from apk archive set and it's giving the above error.

Known workaround

  • Do I have to sign my apk?
  • What's the recommended way if I want to install the debug application from APK set archive without signing it.

Environment:
OS: MAC OS High Sierra : 10.13.4
Device : Pixel 2XL

Create project .gitignore

Is your feature request related to a problem? Please describe.
I use IntelliJ IDE and it generates a lot of local files like *.iml and .idea. Also, Gradle creates the .gradle folder to store caches etc. These files shouldn't be committed/pushed, and anyone can submit it by error.

Describe the solution you'd like
Create .gitignore with common Java, Gradle and IDE ignored files, like

build/
*.iml
.gradle/
.idea/

WDYT?

how to use "build-bundle" command to build a bundle?

how to use "build-bundle" command to build a bundle?

I have an android project with two modules,so how should I do to build a bundle with "build-bundle" command ?

Should I convert the module to an "zip" file? I tried but bundletools show me the message:

build-bundle --modules=/Desktop/develop/MusicLive/AppBundle/app,/Desktop/develop/MusicLive/AppBundle/dynamic_feature1 --output=/Desktop/AppBundle/result.aab 

image

build-bundle --modules=/Desktop/develop/MusicLive/AppBundle/app.zip,/Desktop/develop/MusicLive/AppBundle/dynamic_feature1.zip --output=/Desktop/AppBundle/result.aab 

image

how to add bundletool.jar to the path

Sorry to bother , i am no developer but a tester ,and i am little confused about add the .jar to the path which i can't find bundletool.jar with 'which'command .the location of .jar is d:\bundle
and i add the path to the system enviournment . but the appium-doctor still cannot find the .jar

Really thanks for the help!

get-device-spec does not check persist.sys.locale

Describe the bug
budletool get-device-spec returns device's supportedLocales. I'm using Japanese locale on my Nexus 5X (8.1.0). But get-device-spec returns only en-US locale as follows:

{
  "supportedAbis": ["arm64-v8a", "armeabi-v7a", "armeabi"],
  "supportedLocales": ["en-US"],
  "screenDensity": 420,
  "sdkVersion": 27
}

Bundletool version(s) affected
Version: [e.g. 0.3.3]

To Reproduce
Connect Nexus 5X with Japanese locale and execute next command

java -jar ~/Downloads/bundletool-all-0.3.3.jar get-device-spec --output=/tmp/1.json

Expected behavior
"ja-JP" is included in supportedLocales section

Known workaround
none

Environment:
OS: Android 8.1.0

Additional context
Need to check persist.sys.locale property

Error building apks at release mode with Dexguard

Hi good afternoon!
I'm trying to build an android application at release version with the latest Dexguard version (8.03.04). I generated the bundle from Android Studio 3.2.1 by the "Build Bundle" button.

When I execute the bundletool (version 0.7.2) command build-apks with flags connected device and the flags with the information about with my keystore credentials the ouput is:

[BT:0.7.2] Error: Path of targeted native directory must be in format 'lib/' but found ' '.

image

I checked the bundletool code and I found this validation:
https://github.com/google/bundletool/blob/master/src/main/java/com/android/tools/build/bundletool/validation/NativeTargetingValidator.java#L52

looking for, I thinks, this folder:
https://github.com/google/bundletool/blob/master/src/main/java/com/android/tools/build/bundletool/model/BundleModule.java#L59

and my bundle has this folder inside base folder with the following subfolders:
image

image

I'll apreciate some help or comments about this issue.
Thanks a lot! :)

There is insufficient memory for the Java Runtime Environment to continue.

Describe the bug
A clear and concise description of what the bug is.

Bundletool version(s) affected
Version: [e.g. 0.3.3] 0.7.1

Stacktrace

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/carlos/Downloads/bundletool-all-0.7.1.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000625a00000, 1065353216, 0) failed; error='Not enough space' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1065353216 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/carlos/Downloads/hs_err_pid22129.log

To Reproduce
Seems to happen sometimes when running bundletool to generate the signed apks.

Expected behavior
Create the signed apks without the crash.

Environment:
OS: [e.g. iOS 10.3.3]
Ubuntu 18.10

I can attach the hs file it generated but I edited it to remove private parts of my command line.

MacOS adb path not retrieved

Describe the bug
the command line tool is always asking me about adb path, even though ANDROID_HOME is set correctly.

Bundletool version(s) affected
0.3.3

To Reproduce
Steps to reproduce the behavior.
java -jar bundletool-all-0.3.3.jar get-device-spec --output...
"Unable to determine the location of ADB. Please set the --adb flag or define ANDROID_HOME environment variable.
com.android.tools.build.bundletool.exceptions.CommandExecutionException: Unable to determine the location of ADB. Please set the --adb flag or define ANDROID_HOME environment variable."
adb path is already set, terminal accepts adb command.

Environment:
MacOs

Why the getPackageArchiveInfo function of PackageManager can not get PackageInfo from the Split Apk made by Bundletool.

Describe the bug
Why the getPackageArchiveInfo function of PackageManager can not getPackageInfo from the Split Apk made by Bundletool.
I want to read split apk made by bundletool packageinfo When I used the func getPackageArchiveInfo of PackageManager ,but the return result is null.

Bundletool version(s) affected
Version: [e.g. 0.6.0]

Stacktrace
Copy all of the output of the command, including the stacktrace if visible.

To Reproduce
Steps to reproduce the behavior.
Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

Expected behavior
if we can read the packageInfo.

Known workaround
If you have found a workaround, please specify what it is.

Environment:
Android N

Additional context
Add any other context about the problem here.

Integrate bundletool into AndroidStudio

Is your feature request related to a problem? Please describe.
The command line tool is very hard to use, lots of commands, lots of paths need to be set, etc.
It also seems to barely work on Mac.

Describe the solution you'd like
Could you just integrate building bundles, extracting apks from bundles and installing correct apk per connected device into the Android Studio configuration?
The reason why I want to do this is that the bundle is broken compared to my normal release apk, it produces different, wrong results. So I need to test my bundle before hand, and the only way to do this is via this command line tool

Describe alternatives you've considered
The alternative would be to create my own run configuration in AndroidStudio?

Add a way to install all modules with install-apks

Is your feature request related to a problem? Please describe.
Currently you have to manually list all modules on install-apks --modules to install everything. Ideally we'd have a way install everything easily.

Describe the solution you'd like
Ideally I'd like a install-apks --all-modules flags to install all modules in the .apks file

Describe alternatives you've considered
install-apks --modules <list_all_modules>

Bundletool doesn't respect ANDROID_SERIAL

Is your feature request related to a problem? Please describe.

Most Android tools support setting the ANDROID_SERIAL environmental variable when working with multiple devices. It looks like your tool has a --device-id flag, which probably does the same thing.

Describe the solution you'd like

Ok, so why is --device-id not good enough? The environmental variable is nice because it applies recursively to subprocesses. This means I can write a script which calls bundletool, and I don't have to add an explicit --device-id flag to my script just to make bundletool work.

ANDROID_SERIAL is documented in the adb help pages (it's equivalent to adb's -s flag).

Describe alternatives you've considered

Alternative is for me to explicitly check for my env var and pass it to bundletool with a flag. But it's pretty standard for tools to respect ANDROID_SERIAL, so I don't think this is an unreasonable thing to add to bundletool itself.

Additional context

No additional context, but I'm more than happy to implement this myself if you're willing to integrate it.

Make it easy to install app from aab binary

Is your feature request related to a problem? Please describe.

As of now installing app from aab is two or more steps, many usually use bundletool to install the app, so its better if we have single step to install the app from aab

We share aab to testing team for testing, they use different devices to test these, one of the simple workflow they follow is to install the aab to connected device however thats not a single step, so we are using a wrapper script to do that.

Describe the solution you'd like

bundletool install-aab <aab-path> --use-debug-certificate

  • remove intermediate step of converting aab -> apks
  • use-debug-certificate or similar flags can be used to sign the apk on the fly using android debug keystore

Describe alternatives you've considered

https://gist.github.com/riyaz/b97d3a80858abd5c0f34a4ce1104ad3d

As of now I'm using above wrapper script, it would be nice to have this inbuilt for testing purposes

when build the apks, there are two base-master.apk (base-maseter.apk, base-master2.apk)

Describe the bug
when build the apks, there are two base-master.apk (base-maseter.apk, base-master2.apk)
why there are two base-master.apk ?
Bundletool version(s) affected
Version: [e.g. 0.8.0]

Stacktrace

To Reproduce
Steps to reproduce the behavior.
Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

Expected behavior
A clear and concise description of what you expected to happen.

Known workaround
If you have found a workaround, please specify what it is.

Environment:
OS:window 10

Additional context
Add any other context about the problem here.

Integrate bundletool to adb command

To make it simpler to install app from aab binary, it would be nice if bundletool can be part of android's adb command line, this will be mostly useful for non-devs like testing team they all have adb installed already.

As of now we need another tool to install in all the machines who needs to install app from aab, isn't better if adb natively support to install from aab format and also uses android debug certificate for signing.

as of now i'm using this wrapper script.

NullPointerException while installing with bundle-tool

Describe the bug
When trying to install the generated APKs from the AAB, the bundle-tool is not able to install it with Android 4.2 and 4.3 (never tested with 4.4).
Android >= 5.0 are working fine (the SAME files).

Bundletool version(s) affected
Version: [e.g. 0.8.0]

Stacktrace
[BT:0.8.0] Error: null
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
at com.google.common.base.Joiner.toString(Joiner.java:454)
at com.google.common.base.Joiner.appendTo(Joiner.java:106)
at com.google.common.base.Joiner.appendTo(Joiner.java:154)
at com.google.common.base.Joiner.join(Joiner.java:197)
at com.google.common.base.Joiner.join(Joiner.java:187)
at com.google.common.base.Joiner.join(Joiner.java:205)
at com.android.ddmlib.Device.installRemotePackage(Device.java:1024)
at com.android.ddmlib.Device.installPackage(Device.java:902)
at com.android.ddmlib.Device.installPackage(Device.java:880)
at com.android.ddmlib.Device.installPackage(Device.java:869)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:113)
at com.android.tools.build.bundletool.device.ApksInstaller.installOnDevice(ApksInstaller.java:94)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:82)
at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:44)
at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$3(InstallApksCommand.java:166)
at com.android.tools.build.bundletool.io.TempFiles.lambda$withTempDirectory$0(TempFiles.java:68)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:52)
at com.android.tools.build.bundletool.io.TempFiles.withTempDirectory(TempFiles.java:71)
at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:144)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:88)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:46)

To Reproduce
At least our app with 3rd party libs is not able to install it via bundle-tool on Android <5 (4.2 and 4.3 tested).
It works fine, when the same AAB file is uploaded into the store (minimum version of our app is 4.2).

Expected behavior
It should install the apk like it install it from the PlayStore.

How do i share the aab with testing team / others during testing cycle?

AAB format generated during build process is not testing cycle friendly ,

Expectation :

Way to share the bundle (maybe aab) to testing team so that they can install as per their respective phone config using bundletool

Issues :

  1. Since apks file is too big (~700MB) to share its not suitable for sharing
  2. aab file is not suitable for sharing since bundletool does not accept aab as input
  3. assume even if i share aab and ask testing team to convert it to apks and then to install it in device, to convert aab to apks we need keystore pass / key pass which cannot be shared with everyone.

Workaround :

As of now I'm creating a signed universal apk and sharing it with the team for testing, however this is not the apk users are going to use

Question about behavior of extract-apks subcommand with --device-spec flag

Describe the bug

I have an app that contains native libraries for multiple ABIs (armeabi-v7, arm64-v8a, x86)
and wanted to validate ABI-specific apks generated by bundletool. However only single ABI-specific apk is extracted from APK Set file

Bundletool version(s) affected
Gradle version: 4.9
Bundletool version: 0.5.0
Android Gradle plugin version: 3.2.0-beta04

Stacktrace
N/A

To Reproduce

  1. Have following App Bundle config in build.gradle
    bundle {
        abi {
            enableSplit = true
        }
        density {
            enableSplit = false
        }
        language {
            enableSplit = false
        }
    }

  1. Generate App Bundle via gradle ./gradlew bundleDebug
  2. Generate APK set archive using command
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
  1. Validate archive contents and see that splits directory contains files base-master.apk, base-arm64_v8a.apk, base-armeabi_v7a.apk, base-x86.apk
  2. Extract apks from archive using command:
bundletool extract-apks --apks=/MyApp/my_app.apks --output-dir=/MyApp/apks/ --device-spec=spec.json

Where spec.json is

{
    "supportedAbis": ["armeabi", "armeabi-v7a", "arm64-v8a"],
    "sdkVersion": 27,
    "screenDensity": 420,
    "supportedLocales": ["en"]
}
  1. As a result only base-master.apk and base-armeabi_v7a.apk are extracted but not base-arm64_v8a.apk
  2. However if order of elements in supportedAbis is changed for example to
{
    "supportedAbis": ["armeabi", "arm64-v8a", "armeabi-v7a"],
    "sdkVersion": 27,
    "screenDensity": 420,
    "supportedLocales": ["en"]
}

Then base-arm64_v8a.apk is extracted but base-armeabi_v7a.apk is not.

Expected behavior
I assumed that extract-apks subcommand would extract all apks that match with conditions specified in json spec file. Is my assumption is incorrect and bundletool extracts only first matched apk?

Known workaround
By changing the order of elements in supportedAbis arrays I was able to extract apks for both armeabi-v7a and arm64-v8a.

Environment:
OS: Fedora 28 x86-64

Additional context
N/A

Error: Installation of the app failed on bundletool install-apks command

Describe the bug
Hi! I'm trying to install the .apks on my Nexus 6P but I'm getting [BT:0.4.1] Error: Installation of the app failed. 100% of the time, but when I try to install on my Asus Zenfone Go it works. I tried signing with release keys, debug keys, building from command line and Android Studio but no success. I have some native/cpp code in my app and I got this abi related error once: E/SplitApkInstaller: Failed to finalize session : INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113, weird that this error just showed up once.

Bundletool version(s) affected
Version: 0.4.1

Stacktrace

[BT:0.4.1] Error: Installation of the app failed.
com.android.tools.build.bundletool.exceptions.InstallationException: Installation of the app failed.
	at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:47)
	at com.android.tools.build.bundletool.exceptions.InstallationException$Builder.build(InstallationException.java:41)
	at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:98)
	at com.android.tools.build.bundletool.device.ApksInstaller.installOnDevice(ApksInstaller.java:89)
	at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:78)
	at com.android.tools.build.bundletool.device.ApksInstaller.installApks(ApksInstaller.java:45)
	at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$3(InstallApksCommand.java:145)
	at com.android.tools.build.bundletool.io.TempFiles.lambda$withTempDirectory$0(TempFiles.java:67)
	at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:51)
	at com.android.tools.build.bundletool.io.TempFiles.withTempDirectory(TempFiles.java:70)
	at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:129)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:85)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)
Caused by: com.android.ddmlib.InstallException
	at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:100)
	at com.android.ddmlib.Device.installPackages(Device.java:926)
	at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:92)
	... 10 more
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
	at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:557)
	at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:383)
	at com.android.ddmlib.Device.executeShellCommand(Device.java:573)
	at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:86)
	... 12 more

To Reproduce

./gradlew clean cleanBuildCache bundleRelease
java -jar bundletool.jar build-apks --bundle=./bundle.aab --output=./my_app.apks --ks=./release.keystore --ks-pass=pass:[pass] --ks-key-alias=[alias] --key-pass=pass:[pass]
java -jar bundletool.jar install-apks --apks=./my_app.apks

Expected behavior
I expect the app to be installed in my Nexus 6P like it does for the Asus Zenfone go.

Environment:
OS: macOS high sierra 10.13.4

Documentation

README.MD should maybe mention Google Play instead of Play Store.

Installation size on devices significantly larger with bundletool

Our app compiles to ~45mb .apk in debug build, and occupies similar space on devices.
we used the bundle-tool (BT) to build a .aab file and simulate installations - results were promising!
BT reported that final installations would range between 24mb to 37mb, while the core package would be 20mb.

Problem:
end result on devices is significanlty larger - as seen in the devices settings/app-manager

  • for Nexus5x (xxhdpi, api 26)- installation with .aab occupies 58mb (compared to ~45mb with .apk)
  • for Samsung Note4 (xxxhdpi, api 23) - installation occupies 129mb(!!!!)

what is happening here? where are all these extra mb's be coming from??

Additional context:

  • .aab was compiled and installed on devices using both Android-Studio and bundle-tool independently, several times

  • our app does not have any native libraries, is written in Java and Kotlin, no flavores, and one language

  • .aab based on debug-build

  • .aab was analysed with apk-analyser and confirmed BT report

  • clean installations ensured (previous version explicitly deleted)

  • workstation: MacbookPro 13", 2015, Mojave 10.14.2

  • IDE: Android Studio 3.3
    Build #AI-182.5107.16.33.5199772, built on December 25, 2018
    JRE: 1.8.0_152-release-1248-b01 x86_64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    macOS 10.14.2

  • this problem seems similar to issue #41, which was closed without being resolved

Bundletool version(s) affected
Version: 0.8.0

app install with bundle
app install with apk

Inconsistency in bundletool's "get-device-spec" and "adb shell wm density" adb gives screen density as 640 and bundle tool gives 480. Bundletool version: bundletool-all-0.4.1.jar

Connected Samsung Glaxy S 8 device with laptop, ran following command on terminal.
adb shell wm density
Result:
Physical density 640
overridden density 480

Then reset density by following command
adb shell wm density reset

then again run
adb shell wm density
result: Physical density 640

Please note, now no overridden density in result output. Since it has been reset.

Now jump to bundletool path and run the following command to get device-spec json file:
java -jar bundletool-all-0.4.1.jar get-device-spec --output=deviceName.json

output:
{
"supportedAbis": ["arm64-v8a", "armeabi-v7a", "armeabi"],
"supportedLocales": ["en-GB"],
"screenDensity": 480,
"sdkVersion": 24
}

Why bundletool is still giving old overridden density(480) as screen density?

Bundletool Version: 0.4.1

Steps to reproduce the behavior.
Override the screen density of any connected device with laptop by following command:
adb shell wm density 480

then reset it again by cmd:
adb shell wm density reset

then try get device-spec .json file. It will take overridden density. Please let me know for any query/concern.

VersionCodeMissingException - Gradle

Describe the bug
I'm not sure if this problem originates when Android Studio generates a .aab or when bundletool attempts to generate a .apks but I figured this was the best place to ask.

I'm currently exploring adding app bundle support to an application that I maintain but whenever I attempt to generate a .apks via bundletool I get the following error:

com.android.tools.build.bundletool.exceptions.manifest.ManifestVersionException$VersionCodeMissingException: Version code not found in manifest.
	at com.android.tools.build.bundletool.model.AndroidManifest.lambda$getVersionCode$15(AndroidManifest.java:288)
	at java.base/java.util.Optional.orElseThrow(Optional.java:397)
	at com.android.tools.build.bundletool.model.AndroidManifest.getVersionCode(AndroidManifest.java:288)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Collections$2.tryAdvance(Collections.java:4727)
	at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4735)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at com.android.tools.build.bundletool.validation.AndroidManifestValidator.validateSameVersionCode(AndroidManifestValidator.java:58)
	at com.android.tools.build.bundletool.validation.AndroidManifestValidator.validateAllModules(AndroidManifestValidator.java:47)
	at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:75)
	at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleUsingSubValidator(ValidatorRunner.java:69)
	at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundle$3(ValidatorRunner.java:58)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
	at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundle(ValidatorRunner.java:58)
	at com.android.tools.build.bundletool.validation.AppBundleValidator.validate(AppBundleValidator.java:73)
	at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:97)
	at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:52)
	at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:439)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:77)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)

This is not a new project. It has been used to generate and publish traditional APKs for many years now. The version code is currently defined in the build.gradle file like so...

android {

    ...

    defaultConfig {
        versionCode VERSION_CODE_HERE
        versionName VERSION_NAME_HERE

        ...

    }

    ...

}

The only way I've been able to get around this exception is to add version info to the project's manifest like so...

<?xml version="1.0" encoding="UTF-8"?>
<manifest package="com.example.package"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:versionCode="VERSION_CODE_HERE"
    android:versionName="VERSION_NAME_HERE">
    
    ...

</manifest>

It feels weird to have to reintroduce version info into the project's manifest. Is this behavior intentional or is this the result of a bug somewhere in the build process or my project setup? Any help would be greatly appreciated!

A few additional details:

  • .aab generated by Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338
  • Bundletool command used when attempting to generate .apks: bundletool build-apks --bundle=./bundle.aab --output=./output.apks (additional key signing params used but omitted here)

Bundletool version(s) affected
Version: 0.7.2

Stacktrace
Provided in above description.

To Reproduce
Provided in above description.

Expected behavior
bundletool should generate a .apks from the project's .aab.

Known workaround
Provided in above description.

Environment:
OS: MacOS

Additional context
N/A

Add "dump badging" command

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like

We use "aapt dump badging" to get meta data of an .apk file. It's nice to have similar solution for .aab file.

Error while writing the APK Set archive

Describe the bug
I get an error java.nio.file.NoSuchFileException when trying to build the .apks file. The command I'm using is:

bundletool build-apks --bundle=/home/yperess/workspace/myapp/app/build/outputs/bundle/release/bundle.aab --output=/home/yperess/workspace/myapp/build/outputs/apk/release/myapp.apks --ks=/home/yperes/keystores/org.jks --ks-pass=pass:password --ks-key-alias=MyApp --key-pass=pass:password

Bundletool version(s) affected
Version: 0.4.1

Stacktrace

[BT:0.4.1] Error: Error while writing the APK Set archive to '/home/yperess/workspace/myapp/build/outputs/apk/release/myapp.apks'.
com.android.tools.build.bundletool.exceptions.CommandExecutionException: Error while writing the APK Set archive to '/home/yperess/workspace/myapp/build/outputs/apk/release/myapp.apks'.
	at com.android.tools.build.bundletool.exceptions.CommandExecutionException$Builder.build(CommandExecutionException.java:81)
	at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.writeTo(ApkSetBuilderFactory.java:124)
	at com.android.tools.build.bundletool.commands.BuildApksCommand.executeWithTempDir(BuildApksCommand.java:310)
	at com.android.tools.build.bundletool.io.TempFiles.withTempDirectoryReturning(TempFiles.java:51)
	at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:237)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:72)
	at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)
Caused by: java.nio.file.NoSuchFileException: /tmp/ZipBuilder-6188385578339465164.zip.tmp -> /home/yperess/workspace/myapp/build/outputs/apk/release/myapp.apks
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:457)
	at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
	at java.nio.file.Files.move(Files.java:1395)
	at com.android.tools.build.bundletool.io.ZipBuilder.writeTo(ZipBuilder.java:105)
	at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.writeTo(ApkSetBuilderFactory.java:119)
	... 5 more

To Reproduce

bundletool build-apks --bundle=/home/yperess/workspace/myapp/app/build/outputs/bundle/release/bundle.aab --output=/home/yperess/workspace/myapp/build/outputs/apk/release/myapp.apks --ks=/home/yperes/keystores/org.jks --ks-pass=pass:password --ks-key-alias=MyApp --key-pass=pass:password

Expected behavior
Generate a .apks file

Known workaround
If you have found a workaround, please specify what it is.

Environment:
OS: Ubuntu 18.04

Additional context
Add any other context about the problem here.

output flag error

Hello, I am following instructions here - https://developer.android.com/guide/app-bundle/test. It says to run the following command
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks

So I do java -jar bundletool-all-0.5.0.jar build-apks --bundle=~/workspace/git/google/android-dynamic-features --output=my.apk

However, bundletool errors out with the following

Error: Flag --output should be the path where to generate the APK Set. Its extension must be '.apks'.
com.android.tools.build.bundletool.exceptions.ValidationException: Flag --output should be the path where to generate the APK Set. Its extension must be '.apks'.
at com.android.tools.build.bundletool.exceptions.ValidationException$Builder.build(ValidationException.java:49)
at com.android.tools.build.bundletool.exceptions.ValidationException$Builder.build(ValidationException.java:41)
at com.android.tools.build.bundletool.commands.BuildApksCommand$Builder.build(BuildApksCommand.java:265)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:353)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:273)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:73)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)

bundletool build-apks `--connected-device` or `--device-spec` flag/parameter are not working

Describe the bug
I've referred Google IO'18 official session youtube video: https://youtu.be/bViNOUeFuiQ?t=1324 and it says that you can generate the apk set archive for the connected device from the app bundle during testing phase.

I'm trying to run the following command which should generate the apk set for connected device or as per the device-specs. These both commands are not working and giving me the following error.

bundletool build-apks --bundle=app/build/outputs/bundle/debug/bundle.aab --output=my_app.apks --connected-device
bundletool build-apks --bundle=app/build/outputs/bundle/debug/bundle.aab --output=my_app.apks --device-spec=pixel2.json

Bundletool version(s) affected
Version: [e.g. 0.3.3]

Stacktrace
$ bundletool build-apks --bundle=app/build/outputs/bundle/debug/bundle.aab --output=my_app.apks --connected-device

WARNING: The APKs won't be signed and thus not installable unless you also pass a keystore via the flag --ks. See the command help for more information.
[BT:0.3.3] Error: Unrecognized flags: --connected-device
com.android.tools.build.bundletool.utils.flags.ParsedFlags$UnknownFlagsException: Unrecognized flags: --connected-device
at com.android.tools.build.bundletool.utils.flags.ParsedFlags.checkNoUnknownFlags(ParsedFlags.java:90)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:239)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:191)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:72)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)

$ bundletool build-apks --bundle=app/build/outputs/bundle/debug/bundle.aab --output=my_app.apks --device-spec=pixel2.json

WARNING: The APKs won't be signed and thus not installable unless you also pass a keystore via the flag --ks. See the command help for more information.
[BT:0.3.3] Error: Unrecognized flags: --device-spec
com.android.tools.build.bundletool.utils.flags.ParsedFlags$UnknownFlagsException: Unrecognized flags: --device-spec
at com.android.tools.build.bundletool.utils.flags.ParsedFlags.checkNoUnknownFlags(ParsedFlags.java:90)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:239)
at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:191)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:72)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:44)

To Reproduce
Steps to reproduce the behavior.

  • Use the above-mentioned command to install the application to the connected device.

bundletool build-apks --bundle=app/build/outputs/bundle/debug/bundle.aab --output=my_app.apks --connected-device

Expected behavior
It should generate the apk archive set for the connected device or as per the device spec json file.

Known workaround
Don't know

Environment:
OS: MAC, High Sierra 10.13.4
Device : Pixel2 XL

Larger installed size for tablets

Describe the bug
When I run "bundletool install-apks" on tablet, the application installed size was increased from 35MB to 47MB. This is really weird because it works fine with phones. Could you help me understand what is going wrong? Is there anything I should do differently for tablets?

Bundletool version(s) affected
Version: 0.7.2

Environment:
OS: 7.0.0

Know the size of APK that will be installed on a particular device

Generally, developers in any org don't have access to play console. AFAIK, the total APK downloadable size and the total size reduction percentage for a particular device/ all the devices is available only on play console. So, there should be a way by which i can at least know the APK downloadable size for a particular device and the reduction percentage.

I know i can use this command to extract APKs:

bundletool extract-apks
--apks=/MyApp/my_existing_APK_set.apks
--output-dir=/MyApp/my_pixel2_APK_set
--device-spec=/MyApp/bundletool/pixel2.json

But it throws 3 APKs in my output directory. Should i add the size of these three to get the final size?
Anyways, even if i can do that, it would be better if there's a tool for that.

I know this is farfetched but if possible, it can also be made exactly like in Play console i.e all the devices and all the APKs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.