Skip to content

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

Description

@Dolfik1

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: Dolfik1@ead9684

Happy to send this as a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions