You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Android: exclude the main apk deps from the test apk (#6073)
This is related to #6064
### Improvements
- Aligning base module and androidTest dependencies is [no longer
necessary](https://github.com/vaslabs-ltd/compose-samples-with-mill/pull/6/files#diff-35fe6f53838971f482104d05f316647dead2c9fff13e5df4f7f2c7ad200e6a0dL95)
- Properly passing compile classpath to R8 makes the R8 workaround error
-> warning mapping [not
necessary](https://github.com/vaslabs-ltd/compose-samples-with-mill/pull/6/files#diff-35fe6f53838971f482104d05f316647dead2c9fff13e5df4f7f2c7ad200e6a0dL85)
- The test apk size is now greatly reduced (from >20MB to <1MB in most
cases)
- With the new AndroidR8InstrumentedTestsModule , androidTests apk can
also be minified as the `androidGeneratedMinifyKeepRules` is only
available in R8 modules
| App | Mill Size | Gradle Size |
|------ | ----------- | ------------------|
| Jetchat | 760KB | 1019KB |
| JetNews|742KB|999KB|
| Architecture Samples | 4.3MB | 5.6MB |
### Fixes
- Cyclic dependency issue when compiling r classes
- Jetchat android tests
### Implementation details
Introduced a new `AndroidR8InstrumentedTestsModule` which builds the
test apk excluding the dependency tree of the base module (base apk)
with 2 important tasks:
- `androidR8CompileOnlyClasspath` incorporates the whole base apk (but
as a jar file)
- `androidResolvedPackagableMvnDeps` excludes the dependencies of the
base module via `androidPackagableMvnDeps` and is used in place of
`resolvedRunMvnDeps` .
### Extensions
To do the dependency resolution again by excluding the dependency tree,
without breaking the examples, I needed a way to pass the bom to the
`defaultResolver().classpath` . Thus I extended the methods needed and
fixed any MiMa issues with `@unroll` , although I haven't used it
before, this is what I've found from looking around, so please let me
know if this was a mistake
### Further work
Testing a few apps, there was a case where a test dependency was pulling
`com.google.android.material:material` which in turn depends on
appcompat android resources, so aapt2 linking was failing.
I tried to see if `aapt2 link` `-I` argument would be of any help, but
it seems I'm missing something, it appears only one artifact can be
passed to it, tried several usage variations without luck
Gradle incorporates these resources without an issue, so it means we
need to find a way to link the resources against the base module
resources and at the same time avoid duplicate contents
I think it's a very niche use case, as typically runtime usage of these
resources will be done in the base apk. For now, I added the appcompat
explicitly in the androitTest mvnDeps so the linking goes through
0 commit comments