Search code examples
androidandroid-jetpack-composeproguardandroid-r8

How to prevent R8 from removing public Compose Preview methods in release builds?


I'm using airbnb/Showkase library for collecting all previews into a catalog and was exploring the idea of putting an entry point to that catalog browser activity somewhere in admin settings page in production release builds of the app.

When I run a debug build, Showkase does collect all compose preview methods and displays them. But in release builds those methods get removed and hence nothing to display in catalog.

Is there a way to make R8 keep Compose Preview methods in release builds? Maybe a certain proguard rule?


Solution

  • The readme of the Showkase library mentions about adding the following rule when using Proguard:

    -keep public class * extends com.airbnb.android.showkase.models.ShowkaseProvider
    

    There should be no need to additionally keep all Preview annotated methods.