-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Describe the bug
When building with R8 enabled, I encounter build failures due to missing preview data utilities. The library includes stream-video-android-previewdata as compileOnly, but Compose generates ComposableSingletons classes that reference these preview utilities in production code.
ERROR: R8: Missing class io.getstream.video.android.mock.StreamPreviewDataUtils (referenced from: void io.getstream.video.android.compose.ui.components.call.renderer.internal.ComposableSingletons$ScreenShareVideoRendererKt$lambda-2$1.invoke(androidx.compose.runtime.Composer, int))
Missing class io.getstream.video.android.mock.StreamPreviewDataUtilsKt (referenced from: void io.getstream.video.android.compose.ui.components.call.ComposableSingletons$CallAppBarKt$lambda-7$1.invoke(androidx.compose.runtime.Composer, int) and 35 other contexts)
The automatically generated missing_rules.txt file doesn't work:
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn io.getstream.video.android.mock.StreamPreviewDataUtils
-dontwarn io.getstream.video.android.mock.StreamPreviewDataUtilsKt
The only workaround I've found so far is including the preview module in runtime dependencies of the consumer app, even though it adds unnecessary code:
implementation("io.getstream:stream-video-android-previewdata:same-version")
Kotlin generates ComposableSingletons classes that contain lambda references to all Composable functions in a file, including those marked with @Preview. Even though preview functions like ScreenShareVideoRendererPreview() are marked private, the compiler still generates references to them that are accessible from production code.
Suggested Solutions
- Move all preview-specific code to dedicated files in a preview source set that can be excluded from release builds
- Change compileOnly dependency on
stream-video-android-previewdatatoapito ensure it's available in production - Modify the library to avoid using Preview Data Utils directly in Compose Previews, or provide comprehensive ProGuard rules
👉 The first approach is recommended to avoid shipping unnecessary code in production apps.
SDK version
- 1.6.3
To Reproduce
Steps to reproduce the behavior:
- Include the Stream Video Compose UI library in an Android app
- Enable R8
- Try to build the app
Expected behavior
App builds fine.
Device:
Any
Screenshots
None