There is a similar question Another similar question. But it doesn't solve my problem.
I get this error "@Composable invocations can only happen from the context of a @composable function" after building my project, even though the preview is working fine.
This is my code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApp {
SplashUI()
}
}
}
@Composable
fun SplashUI() {
Image(painterResource(R.drawable.logo_voodlee),"content description")
}
@Composable
fun MyApp(content: @Composable () -> Unit) {
MaterialTheme {
Surface(color = Color.Yellow) {
content()
}
}
}
@Preview("MyScreen preview")
@Composable
fun DefaultPreview() {
MyApp {
SplashUI()
}
}
Been stuck at this for hours. Please help me fix this!!!