google / google/bundletool

bundletool leaves 100s of KB of META-INF metadata in output APKs

Open
#356 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
4k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

**Bundletool version(s) affected**
Version: 1.15.6

**To Reproduce**

1. Build an android app release bundle with gradle, and create release APKs. For my testing I'm in the androidx repository and built a sample app into a release app bundle:

```
> ./gradlew benchmark:i-t:mac-target:bundleRelease
> java -jar ~/Downloads/bundletool-all-1.15.6.jar build-apks --bundle=../../out/androidx/benchmark/integration-tests/macrobenchmark-target/build/outputs/bundle/release/macrobenchmark-target-release.aab --output=no-local-testing.apks --overwrite --ks=/home/ccraik/androidx/frameworks/support/development/keystore/debug.keystore --connected-device --ks-key-alias=AndroidDebugKey --ks-pass=pass:android
> ls -lh *.apks
-rw-r--r-- 1 ccraik primarygroup 2252680 Feb 13 07:03 no-local-testing.apks
```

2. Then, look at the amount of metadata included in output APKs:
```
> unzip no-local-testing.apks
> unzip -vl splits/base-master.apk | grep META-INF
63 Defl:N 58 8% 1981-01-01 01:01 2996938b META-INF/com/android/build/gradle/app-metadata.properties
6 Stored 6 0% 1981-01-01 01:01 4e6c51a2 META-INF/com.google.android.material_material.version
5 Stored 5 0% 1981-01-01 01:01 8f7d2509 META-INF/kotlinx_coroutines_android.version
5 Stored 5 0% 1981-01-01 01:01 8f7d2509 META-INF/kotlinx_coroutines_core.version
5 Stored 5 0% 1981-01-01 01:01 294be821 META-INF/services/A1.u
5 Stored 5 0% 1981-01-01 01:01 0266bbe2 META-INF/services/F1.o
120 Defl:N 118 2% 1981-01-01 01:01 0dcd0bf7 META-INF/version-control-info.textproto
39788 Defl:N 15177 62% 1981-01-01 01:01 2bf94a2f META-INF/BNDLTOOL.SF
773 Defl:N 601 22% 1981-01-01 01:01 e6735010 META-INF/BNDLTOOL.RSA
39661 Defl:N 14723 63% 1981-01-01 01:01 37e23612 META-INF/MANIFEST.MF
```

There's 30KB of compressed bundletool and manifest metadata (3rd column), even though I'm not passing `--local-testing` (which appears to do very little at changing quantities of metadata)

Knowing that I'm using debug keys, and that this is a trivial sample, I took to dumping metadata from production apps on my device, and found most apps retaining much more. Note that this affects 1P google apps, so it wouldn't be an issue with what AGP puts into the bundle.

I wrote a script to capture the amount on apps on my device, to remove any issue with me configuring bundletool incorrectly which shows e.g. 200KB of metadata for nexuslauncher and 100KB for discord
[dumpMetadataCost.zip](https://github.com/google/bundletool/files/14268333/dumpMetadataCost.zip)

Google internal equivalent links: [script](https://paste.googleplex.com/5495790607269888) [sample output](https://paste.googleplex.com/5892849395040256)

**Expected behavior**

Minimal amounts of metadata ends up in output APKs, e.g. 1KB

**Known workaround**

Manually removing metadata from bundle before running

**Environment:**
OS: glinux

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.