Skip to content

Preview Composables are not removed by R8 #890

Description

@kevinguitar

Describe the bug

Hello, I noticed there are a bunch of preview composables that got packaged in the final APK on an Android app that is using purchases-kmp.

I added a rule in proguard to validate that there are no previews being kept

# Ensure all Previews have been stripped https://issuetracker.google.com/issues/157891235#comment6
-checkdiscard class * { @androidx.compose.ui.tooling.preview.Preview <methods>; }
-keepclassmembers,allowshrinking class * { @androidx.compose.ui.tooling.preview.Preview <methods>; }

And there are a lot of previews kept when you assemble a release build:
https://gist.github.com/kevinguitar/53bb31d72b3c23f776455635cd8bb90f

Some environmental information:

  • Platform: Android
  • SDK version: 3.0.3
  • IDE: Android Studio
  • IDE version: Quail 1 | 2026.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions