Skip to content

Conversation

@rossbacher
Copy link
Collaborator

@rossbacher rossbacher commented Jan 28, 2026

This change adds an optional asset-based approach for storing the match index binary data when using KSP with the manifest-generation plugin. Instead of encoding the binary data as strings in the generated registry class, the match index is written as an Android asset file and loaded at runtime via AssetManager.

Key changes:

  • Add shared constants in ManifestGeneration.kt for asset paths and KSP option
  • Generate AssetManager-based registry constructor when useAssetBasedMatchIndex=true
  • Add MergeDeepLinkAssetsTask and RelocateDeepLinkAssetsTask for Gradle plugin
  • Update ManifestGenerationPlugin to handle asset file relocation and merging
  • Add processor tests for asset-based and legacy string-based code generation
  • Update sample tests to use KspLibraryDeepLinkModuleRegistry with assets

The asset-based approach provides:

  • Faster build times (no string chunking/encoding)
  • Faster app startup (direct binary loading, no string decoding)
  • Better APK compression (binary assets compress better than dex strings)

Both modes (asset-based and string-based) are supported per-registry level.

I did run benchmarks on this and in the registry creation (the important benchmark) the asset based approach is bout 20-25% faster, less than I had hoped but this also simplifies this significantly especially once we drop kapt support.

This change adds an optional asset-based approach for storing the match
index binary data when using KSP with the manifest-generation plugin.
Instead of encoding the binary data as strings in the generated registry
class, the match index is written as an Android asset file and loaded
at runtime via AssetManager.

Key changes:
- Add shared constants in ManifestGeneration.kt for asset paths and KSP option
- Generate AssetManager-based registry constructor when useAssetBasedMatchIndex=true
- Add MergeDeepLinkAssetsTask and RelocateDeepLinkAssetsTask for Gradle plugin
- Update ManifestGenerationPlugin to handle asset file relocation and merging
- Add processor tests for asset-based and legacy string-based code generation
- Update sample tests to use KspLibraryDeepLinkModuleRegistry with assets

The asset-based approach provides:
- Faster build times (no string chunking/encoding)
- Faster app startup (direct binary loading, no string decoding)
- Better APK compression (binary assets compress better than dex strings)

Both modes (asset-based and string-based) are supported per-registry level.

#
# Copyright © 2015 the original authors.
# Copyright © 2015-2021 the original authors.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated gradlew to latest as of the used gradle version (9.2.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants