java_resource_extractor exclusion lists miss entries that AGP strips by default (KMP klib metadata, root LICENSE/NOTICE files)

Open Beginner friendly
#535 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
android, kotlin, python

Research direction

Start in src/tools/java_resource_extractor/resource_extractor.py by reading the existing resource exclusion lists and comparing them with the entries named in the issue. Update the filtering so .knm, .kotlin_metadata, linkdata/, and root LICENSE.txt/NOTICE.txt are excluded, while META-INF/*.kotlin_module remains included; verify the resulting APK contents.

Written by the indexing model from the issue text.

Description

src/tools/java_resource_extractor/resource_extractor.py filters out well-known junk from java resources, but its exclusion lists miss a few things that AGP's default packaging rules strip, so they end up in the final APK:

  • .knm files (Kotlin/Native klib metadata)
  • .kotlin_metadata files
  • linkdata/ directories (e.g. commonMain/.../linkdata/*)
  • root-level LICENSE.txt / NOTICE.txt from library jars (the META-INF copies are already covered by the meta-inf directory exclusion)

The klib metadata is only consumed by the Kotlin compiler when compiling against a library; nothing reads it at runtime, so in an APK it's dead weight. In the Gradle world it's common to exclude it via packaging options on top of AGP's defaults. With a KMP-heavy dependency tree (kotlinx-*, androidx KMP artifacts) it adds up — on our app stripping all of the above saved ~0.45 MiB uncompressed (~0.24 MiB compressed).

This deliberately does not touch META-INF/*.kotlin_module, which kotlin-reflect needs at runtime.

Patch: https://github.com/Dolfik1/rules_android/commit/ead968493476d45059224949ec2536755b1a8aab

Happy to send this as a PR.

Dominant language
Java
Stars
203
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_android

All issues in bazelbuild/rules_android

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.