If I add logcat or system.out logs to compose view code, and then view the renders in Android Studio's preview... is it possible somewhere to view those logs?
It would be helpful when debugging views to be able to use the preview window, wondering if there is somewhere to see the logs of the code they run to generate these previews.
This is definitely possible, and is instrumental in debugging broken previews.
First, find the IDE logs (for me, it was Help -> Show Log in Finder). Locate the file, idea.log, and jump to the bottom.
If your preview is crashing, you can find the stack trace here. Otherwise, if you place a println in the top of your composable, for example, you will see the logs show up here when the preview is refreshed. You may have some luck placing the logs elsewhere in your composable function too.
Example:
@Composable
fun MyComposableView() {
println("loading preview")
Box {
LaunchedEffect(true) {
println("### Hello :)")
}
Text("Hello")
}
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With