google / bundletool

Bundletool is a command-line tool to manipulate Android App Bundles
https://g.co/androidappbundle
Apache License 2.0
3.52k stars 385 forks source link

Bundle tool should mirror the default AAPT2 compression settings #256

Closed Bencodes closed 2 years ago

Bencodes commented 2 years ago

Describe the bug

With the default configuration, bundle tool will compress raw values that should not be compressed. It would be great to mirror the default AAPT2 no-compress settings to avoid unnecessary mistakes when migrating to app bundles.

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/tools/aapt2/cmd/Link.cpp#2403

Bundletool version(s) affected Version: 1.8.1

Stacktrace

2021-11-11 17:08:37.910 24800-25124/? E/AndroidRuntime: FATAL EXCEPTION: rx2-io-55
    Process: com.lyft.android.driver.labs, PID: 24800
    android.content.res.Resources$NotFoundException: File res/raw/driver_countdown.mp3 from drawable resource ID #0x7f120043
        at android.content.res.ResourcesImpl.openRawResourceFd(ResourcesImpl.java:385)
        at android.content.res.Resources.openRawResourceFd(Resources.java:1429)
        ...

To Reproduce

Use bundle tool CLI to generate an APK that has raw Android values that should be uncompressed in the APK.

Known workaround

Manually list the no-compress extensions in your bundlle_config:

  ...
  "compression": {
    "uncompressedGlob": [
      "res/raw/*.ogg",
      "res/raw/*.mp3",
      "res/raw/*.mp4",
      ...
    ]
  }
ymakhno commented 2 years ago

Thank you for the report. The correct way of doing this is using uncompressedGlob option which is mentioned in the workaround.

We don't plan to change bundletool behaviour for uncompressed resources at the moment because this will be a breaking change for bundletool.