Status Update
Comments
ea...@google.com <ea...@google.com>
ea...@google.com <ea...@google.com> #2
ja...@gmail.com <ja...@gmail.com> #3
je...@google.com <je...@google.com>
xa...@google.com <xa...@google.com> #4
The request here is to properly control shrinking/obfuscation separately for library and their test. It's useful to want to run a library test with proguard on to ensure that consumers who do the same won't have issues. In particular this help validate that consumerProguardFiles contain what it needs.
au...@google.com <au...@google.com> #5
xa...@google.com <xa...@google.com> #6
ga...@google.com <ga...@google.com>
lo...@gmail.com <lo...@gmail.com> #7
ku...@google.com <ku...@google.com>
ga...@google.com <ga...@google.com>
bi...@google.com <bi...@google.com>
go...@jakewharton.com <go...@jakewharton.com> #8
Any updates on the likelihood of this feature? Would sit nicely in the new DSL :)
si...@gmail.com <si...@gmail.com> #9
feature request
pa...@gmail.com <pa...@gmail.com> #10
Did we reach a point where you're not punting this any further, just deprioritizing it? Is there a way to work around this at the moment without creating a separate app / aar that has different settings just to run/not run R8 on it?
to...@gmail.com <to...@gmail.com> #11
I would completely turn off R8 for test classes, it doesn't make any sense. I want to have obfuscated app to test if it is not break anything, but why test classes?
But testMinifyEnabled is OK, it just should be false by default.
I'm now fighting with it :-(
pa...@gmail.com <pa...@gmail.com> #12
R8 does way more than obfuscation. If you enable R8 you get "tree-shaking" and "inlining" among million other optimizations, which means a few seconds running R8 could save gigabytes of CI (if you store the APKs long term), and minutes uploading, installing and running UI tests because the optimizations add up, especially considering how long it takes to dexopt APKs after install. Additionally tree-shaking could allow running without multidex even with all the AXT libraries as dependencies. (Fixing this issue, would enable all these!)
To answer your question: the reason this issue exists is because when you R8 your production code, you need to R8 your test code too to rename the references from test code to prod code. But we want to have the benefits I listed above, without changing production code.
I agree with it being off by default, and I think you bring a good point that prod and test code needs a totally separate R8 rules file. So we can add -dontobfuscate for tests.
go...@jakewharton.com <go...@jakewharton.com> #13
the reason this issue exists is because when you R8 your production code, you need to R8 your test code too to rename the references from test code to prod code.
Note that is not why I filed the original issue. The original comment is pretty clear that it's for libraries which do not want to run R8 on their main code but want to on their test APK to validate things like the embedded rules.
That said there likely are more uses for the split boolean.
pa...@gmail.com <pa...@gmail.com> #14
Yep, I saw that, but they were asking "Why obfuscate (R8) test classes?" as I read it. Anyway, we can see and agree there are many benefits to this change!
pr...@google.com <pr...@google.com> #15
bi...@google.com <bi...@google.com> #16
Updates: we are finalizing the dsl which means this feature needs more time to be landed.
bi...@google.com <bi...@google.com> #17
The change Ifa2e928fe0acbf207264177ffa52d0746181338e is landed and should be available from 8.3 canary 11.
You can enable minification for android test in library projects with following dsl
android {
buildTypes{
debug {
androidTest {
enableMinification = true
}
}
}
}
To add keep rules, please use
android.buildTypes.debug.testProguardFiles('xxx')
bi...@google.com <bi...@google.com> #18
Keep it open until the "keep rule entry points" are documented properly. Currently, users need to add keep rules for test runner classes and the test classes.
bi...@google.com <bi...@google.com> #19
AndroidX folks has tested the new feature and it works well for them. They are adding keep rules like this
# basic protection against junit/androidx.test reflection, shouldn't affect library/test code
-keepclasseswithmembers class androidx.test.** { *; }
-keepclasseswithmembers class org.junit.** { *; }
-dontwarn com.google.errorprone.annotations.MustBeClosed
## keep test classes
-keepclasseswithmembers @org.junit.runner.RunWith class * { *; }
## needed for org.junit.Test annotation to be discoverable by reflection
-keepattributes *Annotation*
Based on the discussion between r8 & androidx, having a complete list of keep rules added by default seems challenging and it is better to let users handle it.
Given the fact that androidx benchmark project is unblocked, mark it as done.
pa...@gmail.com <pa...@gmail.com> #20
bi.../#19 will these rules be publicly available in
cc...@google.com <cc...@google.com> #21
Speaking for AndroidX performance testing - most likely yes, though we haven't decided how these will land in our repository for microbenchmarking. You can follow the R8-for-benchmarks progress at
This rule list is likely incomplete, as it's possible for other test infrastructure with different packages to use reflection internally. If you run into that though, for most use cases, it should be fine to just add extra lines to keep those additional packages.
cc...@google.com <cc...@google.com> #22
In trying to use androidTest.enableMinification
with microbenchmarks in a library module, I noticed two issues:
- classes referenced by manifest entries from tests weren't kept automatically
- only
consumerProguardFiles
was respected (the other twoproguardFiles
options didn't work)
Filed
Description
I think a testMinifyEnabled to sit alongside minifyEnabled would have a nice parallel with testProguardFiles / proguardFiles.