re-enabling app preview in android studio dolphin (2021.3.1)

I’ve used Android Studio since it’s 1.0 release in 2014. I was very happy to move away from Eclipse Android Development Tools to Android Studio. I’ve used that IDE ever since, perhaps not as constantly as I should. But the call for me to write an app is usually few and far between. An opportunity has arisen that may allow me to try my hand at writing an Android app against a fairly recent release (Android 11 minimum). I’d already been play-developing with Jetpack within Android Studio, and I like it. In particular I like how I can define composable previews using the @Composable and @Preview annotations. With the prior version of Android Studio Chipmunk, this opened up a view of the application under development. When you made changes to the code the preview updated automatically. Key to this is that it was automatically enabled. That has changed within Android Studio Dolphin.

Oh dear. Preview isn’t working! What happened? How do I enable it? I found out, but not by searching on Google, especially Stack Overflow. Stack Overflow is the biggest collection of old and useless technical answers I’ve ever seen. I found out how to re-enable preview by poking around.

Ah! There it is! Look at the upper right corner on the file editing window at the three buttons labeled Code, Split, and Design. If you click Split then it will split the editing window and render the preview on the right, like it did with Android Studio Chipmunk. I found this by accident, clicking around the menus and then clicking various buttons. I didn’t know to click Split until the very end, after I’d found out that Design shows the application preview. I don’t know why Split has that name, but to me it means something totally different, i.e. split the edit pane into two vertical edit panes as you would expect if using any other modern editor or IDE such as Visual Studio Code. But Split does indeed show code on the left and the preview on the right.

The other problem with this new behavior is that it’s not sticky between IDE sessions. Shut down the IDE, then open it back up, and while the project is still there, the preview is not. You’ll have to click Split every time you restart the IDE.