Thread
#compose
    g

    Gleno

    1 year ago
    Are
    @Preview
    annotated functions stripped from final binary?
    Bryan Herbst

    Bryan Herbst

    1 year ago
    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

    1 year ago
    Hmm. Okay, I will look into stripping them some other way. They just hold so much junk. 🤪
    Bryan Herbst

    Bryan Herbst

    1 year ago
    In most cases I would assume R8 would strip them if you have minification turned on (and this is an Android app)
    g

    Gleno

    1 year ago
    As unused leaves?
    Bryan Herbst

    Bryan Herbst

    1 year ago
    Yeah- again, just my assumption. Since there are (probably) no references to them, they should be eligible for shrinking.
    g

    Gleno

    1 year ago
    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
    t

    Tonis Ives

    11 months ago
    I’m also wondering about this. Feels weird to add test code (@Preview with fakeData functions), that will be compiled into the release app. It could essentially double the lines of code for @Composables. I’m also interested in using a mocking in @Preview’s, but then the mockk lib would be bundled in the release binary?
    r

    romainguy

    11 months ago
    You can strip them using R8 (which is recommended for various optimizations that will get applied)
    t

    Tonis Ives

    11 months ago
    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