RevenueCat / react-native-purchases

React Native in-app purchases and subscriptions made easy. Support for iOS and Android.
https://www.revenuecat.com
MIT License
776 stars 84 forks source link

Android app crashes when paywall is triggered #1127

Open khlling opened 2 weeks ago

khlling commented 2 weeks ago

Describe the bug Android crashes when a paywall is triggered. I was using V8.2.6

    "react-native-purchases": "8.2.6",
    "react-native-purchases-ui": "8.2.6",

However, I had to downgrade to v7.28.1 and the paywall appears as expected

    "react-native-purchases": "7.28.1",
    "react-native-purchases-ui": "7.28.1",

My code:

import RevenueCatUI, { PAYWALL_RESULT } from "react-native-purchases-ui";

async function presentPaywall(): Promise<boolean> {
    // Present paywall for current offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywall();
    // or if you need to present a specific offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywall({
        offering: offering // Optional Offering object obtained through getOfferings
    });

    switch (paywallResult) {
        case PAYWALL_RESULT.NOT_PRESENTED:
        case PAYWALL_RESULT.ERROR:
        case PAYWALL_RESULT.CANCELLED:
            return false;
        case PAYWALL_RESULT.PURCHASED:
        case PAYWALL_RESULT.RESTORED:
            return true;
        default:
            return false;
    }
}

async function presentPaywallIfNeeded() {
    // Present paywall for current offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywallIfNeeded({
        requiredEntitlementIdentifier: "pro"
    });
    // If you need to present a specific offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywallIfNeeded({
        offering: offering, // Optional Offering object obtained through getOfferings
        requiredEntitlementIdentifier: "pro"
    });
}
  1. Environment
    1. Platform: Android
    2. SDK version: 34
    3. OS version: 14
    4. Xcode/Android Studio version:
    5. React Native version: 0.74.6
    6. SDK installation (CocoaPods + version or manual):
    7. How widespread is the issue. Percentage of devices affected. - All Android devices
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
androidx.compose.ui.platform.AndroidComposeView.<init> (AndroidComposeView.android.kt:218)
androidx.compose.ui.platform.Wrapper_androidKt.setContent (Wrapper.android.kt:77)
androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated (ComposeView.android.kt:251)
androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow (ComposeView.android.kt:283)
android.view.View.dispatchAttachedToWindow (View.java:22662)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3495)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3502)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3502)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3502)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3274)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2741)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:9960)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1406)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1415)
android.view.Choreographer.doCallbacks (Choreographer.java:1015)
android.view.Choreographer.doFrame (Choreographer.java:945)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1389)
android.os.Handler.handleCallback (Handler.java:959)
android.os.Handler.dispatchMessage (Handler.java:100)
android.os.Looper.loopOnce (Looper.java:232)
android.os.Looper.loop (Looper.java:317)
android.app.ActivityThread.main (ActivityThread.java:8592)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:878)

Additional context

RCGitBot commented 2 weeks ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!