Today, I upgraded my Android Studio from Chipmunk to Dolphin, and most of my Composable Previews have stopped working and are giving the error Some issues were found when trying to render this preview
.
On clicking the Show Exception button in the issues panel, I found the following error.
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process null. Make sure to call FirebaseApp.initializeApp(Context) first.
Most of my composables use Firebase Analytics for event logging purposes and hence FirebaseAnalytics
is one of the parameters in almost all the composable functions. Until Android Studio Chipmunk, I was able to show the preview for all the composables by following the below approach.
@Preview
@Composable
private fun DemoPreview() {
MyAppTheme {
Demo(firebaseAnalytics = Firebase.analytics, onClick = {})
}
}
But the above method no longer works for Android Studio Dolphin.
Is there any other way to pass the FirebaseAnalytics
object that makes the Composable Preview work again?