https://kotlinlang.org logo
#compose
Title
# compose
g

Gleno

07/23/2021, 12:44 PM
Are
@Preview
annotated functions stripped from final binary?
b

Bryan Herbst

07/23/2021, 12:55 PM
No-
@Preview
functions can be used just the same as any other Composable. Simply having
@Preview
doesn’t guarantee that the composable is safe to be stripped.
g

Gleno

07/23/2021, 12:57 PM
Hmm. Okay, I will look into stripping them some other way. They just hold so much junk. 🤪
b

Bryan Herbst

07/23/2021, 12:58 PM
In most cases I would assume R8 would strip them if you have minification turned on (and this is an Android app)
👆 1
g

Gleno

07/23/2021, 12:59 PM
As unused leaves?
b

Bryan Herbst

07/23/2021, 1:01 PM
Yeah- again, just my assumption. Since there are (probably) no references to them, they should be eligible for shrinking.
g

Gleno

07/23/2021, 1:03 PM
Yeah, makes sense. But it’s strange to rely on R8 magic to strip out test code. Hmm, maybe that’s where @preview functions should go. #philosoraptor
r

romainguy

10/05/2021, 2:57 AM
You can strip them using R8 (which is recommended for various optimizations that will get applied)
🙌 1
t

Tonis Ives

10/05/2021, 2:59 AM
Ok thanks I will try
I wonder why Google doesn’t mention anything about R8 in the tutorial.
Maybe R8 is obvious for most of developers