install-apks --allow-downgrade flag not working
Describe the bug
I'm using bundletool to generate *.apks from *.aab file, and then to install it to android device. Installing previous version (lower one than currently installed) results in error:
E/SplitApkInstallerBase: Failed to commit install session 460987557 with command cmd package install-commit 460987557. Error: INSTALL_FAILED_VERSION_DOWNGRADE
Using flag --allow-downgrade doesn't change anything.
Bundletool version(s) affected Version: 1.6.1, 1.10.1
Stacktrace Output:
The APKs have been extracted in the directory: C:\Users\SEBAST~1\AppData\Local\Temp\6570401835384981209
The APKs have been extracted in the directory: C:\Users\SEBAST~1\AppData\Local\Temp\6570401835384981209
10:08:34 E/SplitApkInstallerBase: Failed to commit install session 460987557 with command cmd package install-commit 460987557. Error: INSTALL_FAILED_VERSION_DOWNGRADE
[BT:1.10.0] Error: Installation of the app failed.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Installation of the app failed.
at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:192)
at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$2(InstallApksCommand.java:214)
at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:81)
at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:43)
at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:214)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)
Caused by: com.android.ddmlib.InstallException: Failed to commit install session 460987557 with command cmd package install-commit 460987557. Error: INSTALL_FAILED_VERSION_DOWNGRADE
at com.android.ddmlib.SplitApkInstallerBase.installCommit(SplitApkInstallerBase.java:99)
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:85)
at com.android.ddmlib.internal.DeviceImpl.installPackages(DeviceImpl.java:1166)
at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:176)
... 6 more
To Reproduce
Building *.apks from *.aab with this command:
java -Xmx1024m -jar lib/bundletool-all.jar build-apks --ks=*** --ks-pass=pass:*** --ks-key-alias=*** --key-pass=pass:*** --bundle "%1" --output "%1.apks" --local-testing
Then installing using:
java -Xmx1024m -jar lib/bundletool-all.jar install-apks --allow-downgrade --apks="%1"
or
java -Xmx1024m -jar lib/bundletool-all.jar install-apks --allow-downgrade=true --apks="%1"
Expected behavior If I understand correctly, build should be installed normally as usual.
Known workaround Uninstall old version, install new one.
Environment:
Windows 10, cmd.exe, java version "1.8.0_231"
also checked on MacOS 12.1 with java version "1.8.0_333", same error.
Additional context
Using --local-testing flag while building *.apks because I'm using Google Play Asset Delivery. Don't know if that matters, because installing builds with higher version number than currently installed works like a charm.
Same problem here. I use bundletool 1.17.1.