Skip to content

Conversation

vaslabs
Copy link
Contributor

@vaslabs vaslabs commented Oct 8, 2025

For #5961

Implementation

  • Add the outer AndroidAppModule in the compileModuleDeps instead of moduleDeps
  • Fix some packaging mappings to use run resolved deps
  • Fix the compile only classpath to pass the compileModuleDeps classpaths too
  • By having instrumented tests inherit the androidDefaultProguardFileNames from the parent module, the android tests are working. It's not clear to me why, I found it due to some trial and error. To achieve this kind of inheritance without major rewiring I've moved the method to AndroidAppModule

Other fixes and cleanups

  • Somehow androidtodo had a wrong namespace, maybe a find and replace mishap
  • Removed an unnecessary dep from androidtodo test module

Outcome

This avoids packaging the main (app) module dependencies and source code into the test apk.

Result (Jetsnack)

image

Future work

I had some difficulties reaching this point and I think the 13MB reduction is very satisfiable at this stage. In the gradle's case, it appears some classes are erased by R8 but I haven't pinpointed exactly how it does it.

@vaslabs
Copy link
Contributor Author

vaslabs commented Oct 10, 2025

the included sample apps are passing but I get failures in jetsnack when running the tests

@vaslabs
Copy link
Contributor Author

vaslabs commented Oct 10, 2025

Managed to make it work

image

it's not in the <1MB level of gradle yet, but it's getting there.

@vaslabs
Copy link
Contributor Author

vaslabs commented Oct 10, 2025

need only to fix the Android Res so leaving this as a draft for now

@vaslabs
Copy link
Contributor Author

vaslabs commented Oct 10, 2025

@vaslabs vaslabs marked this pull request as ready for review October 10, 2025 13:36
@vaslabs
Copy link
Contributor Author

vaslabs commented Oct 10, 2025

I think overall it's an improvement on the build flow (some fixes to pick run deps for tests and some transitive dependencies on android resources) and reduces the android test apk by a lot (13-15MB reduction) in most of the cases.

Ready for review @lihaoyi @lefou

@vaslabs vaslabs changed the title Android: Test apk size reduction - basic idea Android: Test apk size reduction Oct 10, 2025
@lihaoyi lihaoyi merged commit 008e945 into com-lihaoyi:main Oct 10, 2025
43 checks passed
@lefou lefou added this to the after 1.0.6 milestone Oct 12, 2025
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.

3 participants