I have the issue that whenever I have a multi-module project, all Jetpack Compose UI previews except for the ones in the app module display an additional TopAppBar with the text androidx.compose.ui.tooling.PreviewActivity
when being executed on a device. You can see the result here:
When only looking at a preview without executing it, the TopAppBar does not show.
The issue appears in the simplest multi-module project, where both modules only contain a single preview composable, too. This leads me to believe it’s not caused by a complex setup. I already tried removing and adding various things in the build.gradle file and the manifest but nothing seems to help.
App module:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
ComposePreviewWithAdMobTheme {
}
}
}
}
@Preview
@Composable
fun Preview() {
Text("Preview!")
}
Core module:
@Preview
@Composable
fun CorePreview() {
Text("CorePreview!")
}
As mentioned before, the app module preview works fine whilst the other shows the additional TopAppBar.
Has anybody faced similar difficulties and can help me?
Thank you.