Android Crashes with ViewTreeLifecycleOwner not found from android.widget.FrameLayout
- [x] I have updated Purchases SDK to the latest version
- [x] I have read the Contribution Guidelines
- [x] I have searched the Community
- [x] I have read docs.revenuecat.com
- [x] I have searched for existing Github issues
Describe the bug When using the <RevenueCatUI.Paywall> component android crashes with the following
** <Modal
animationIn="slideInUp"
animationInTiming={350}
animationOut="slideOutDown"
animationOutTiming={350}
backdropColor={palette.slate100}
onAccessibilityEscape={onClose}
onBackButtonPress={onClose}
onBackdropPress={onClose}
onSwipeComplete={onClose}
backdropOpacity={0.7}
isVisible={isVisible}
deviceWidth={width}
deviceHeight={height}
style={{
borderTopLeftRadius: 24,
borderTopRightRadius: 24,
backgroundColor: palette.inverted,
margin: 0,
marginTop: 60,
// padding: 16,
paddingTop: 30,
}}
>
<RevenueCatUI.Paywall
onPurchaseCompleted={handlePurchase}
onDismiss={onClose}
options={{ displayCloseButton: true }}
/>
</Modal>
**
FATAL EXCEPTION: main
Process: com.stridekick.Stridekick.dev, PID: 14526
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.FrameLayout{fa35aa8 V.E...... ......I. 0,0-0,0}
at androidx.compose.ui.internal.InlineClassHelperKt.throwIllegalStateExceptionForNullCheck(InlineClassHelper.kt:30)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer(WindowRecomposer.android.kt:466)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer$default(WindowRecomposer.android.kt:327)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.LifecycleAware$lambda$0(WindowRecomposer.android.kt:170)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.$r8$lambda$PmWZXv-2LDhDmANvYhil4YZYJuQ(Unknown Source:0)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$$ExternalSyntheticLambda0.createRecomposer(Unknown Source:0)
at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:226)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:302)
at androidx.compose.ui.platform.AbstractComposeView.resolveParentCompositionContext(ComposeView.android.kt:251)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:258)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:290)
-
Environment
- Platform: Android/React-Native
- SDK version: 8.11.8
- React Native version: 71
- How widespread is the issue. Percentage of devices affected: all
-
Steps to reproduce, with a description of expected vs. actual behavior Try to open the paywall component.
Overall the solution of using the presentPaywall function (which is what I've seen others recommend) is not good enough. It doesn't contain the hooks for "onPurchaseCompleted'. If that method mimicked the ui component we would love to use it. As it stands we have to put the component in a modal due to the limitations of the method.
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
I believe it is the modal component I have that is causing the issue but this makes the sdk pretty limited. Would y'all ever add the callbacks to the presentPaywall method? Overall I think the paywall ui component and method should have parity in that respect.
Hello @HilSny
Thanks for reporting the issue. I've been able to reproduce just by wrapping the Paywall view in a Modal component:
<Modal>
<RevenueCatUI.Paywall/>
</Modal>
And I totally agree the presentPaywall function should provide the same callbacks as the Paywall view component.
As a temporary workaround while we fix this issue, if your app uses react-navigation, you could try to use their modal functionality:
https://reactnavigation.org/docs/modal
Awesome, that would be so great. I actually like how the modal presents better with presentPaywall but don't want to use it without the callbacks. As for react-navigation, that works great! Thanks for the suggestions.
Reopening issue. It was closed due to a failing automation. Sorry about that.