Skip to main content

Hey there,
Fetching the offers works as expected, but purchasing them results in an app crash.
The crash only happens on android, ios works fine.

I am on react-native-purchases v4.5.0.
Testing on a Real Android device
I am coming from the react-native-iap (5.2.14) package, I uninstalled the react-native-iap package already, but I am not sure if it might is related to that lib, something i forgot to clean up?


I checked that the Purchases instance isConfigured:

const configured = await Purchases.isConfigured();

I tried both methods, purchaseProduct and purchasePackage, both crashed.


LOGS:

revenueCat Logs:

💰 Retrieved skuDetailsList: SkuDetails: {"productId":"com.docomondo.yearly","type":"subs","title":"docomondo Premium (docomondo - dein smarter Dateimanager)","name":"docomondo Premium","price":"CHF 42.00","price_amount_micros":42000000,"price_currency_code":"CHF","description":"Benefit from all available Features!","subscriptionPeriod":"P1Y","freeTrialPeriod":"P4W2D","skuDetailsToken":"AEu..."}

💰 com.docomondo.yearly - SkuDetails: {"productId":"com.docomondo.yearly","type":"subs","title":"docomondo Premium (docomondo - dein smarter Dateimanager)","name":"docomondo Premium","price":"CHF 42.00","price_amount_micros":42000000,"price_currency_code":"CHF","description":"Benefit from all available Features!","subscriptionPeriod":"P1Y","freeTrialPeriod":"P4W2D","skuDetailsToken":"AEu..."}

💰 Purchase started - product: com.revenuecat.purchases.models.ProductDetails@69d410c null

💰 Purchasing product: com.docomondo.yearly

 

crash logs android studio:

    --------- beginning of crash
2021-12-27 21:50:20.811 17807-17807/com.docomondo.manager E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.docomondo.manager, PID: 17807
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
        at com.android.billingclient.api.BillingClientImpl.launchBillingFlow(com.android.billingclient:billing@@4.0.0:56)
        at com.revenuecat.purchases.google.BillingWrapper$launchBillingFlow$1.invoke(BillingWrapper.kt:226)
        at com.revenuecat.purchases.google.BillingWrapper$launchBillingFlow$1.invoke(BillingWrapper.kt:53)
        at com.revenuecat.purchases.google.BillingWrapper.withConnectedClient(BillingWrapper.kt:593)
        at com.revenuecat.purchases.google.BillingWrapper.launchBillingFlow(BillingWrapper.kt:225)
        at com.revenuecat.purchases.google.BillingWrapper.access$launchBillingFlow(BillingWrapper.kt:53)
        at com.revenuecat.purchases.google.BillingWrapper$makePurchaseAsync$2.invoke(BillingWrapper.kt:216)
        at com.revenuecat.purchases.google.BillingWrapper$makePurchaseAsync$2.invoke(BillingWrapper.kt:53)
        at com.revenuecat.purchases.google.BillingWrapper$executePendingRequests$1$1$1.run(BillingWrapper.kt:81)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7839)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

I also downgraded the react-native-purchases version to 4.2.0 because it uses the android billing version v3 instead of v4. Without any success...


Hey @mwerder, thanks for the detailed report, and I’m sorry you’re seeing this crash. I think I have an idea of what could be going on here… 

For some background:

The crash comes from Google’s BillingClient, which we call from our SDK. BillingClient expects that the Android activity passed in to launchBillingFlow (initiated from purchasing functions) has a non-null Intent (see this StackOverflow). One of your customers on the native SDK was setting the intent to null due to some navigation code they were utilizing. 

However, in ReactNative, you aren’t passing in the activity -- we pass it by calling ReactNative’s getCurrentActivity(). I’m going to do some research into how that could be returning an activity with a null intent, but: are you using any other libraries that might modify the Android Activity?

Either way, I think our library is well-poised to provide a fix, or at least a log explaining what’s happening. I’ll get working on that today and let you know when we release it.


Hi @Maddie , thanks for your answer.
We are using the library “react-native-receive-sharing-intent” to receive images and .pdf files.
Maybe this one is interferring?


@Maddie , quick update, we are on the right track! I uninstalled the “react-native-receive-sharing-intent” package, just to check if it really is that library, and now the purchase worked!
Thank you. Now I just have to figure out how to handle both libraries together.


@Maddie found this fix for the library, which makes both work together. Really appreciated your help Maddie!


@mwerder thanks so much for sending all this info, that will be really helpful for future customers! I’m going to add a log when this crash happens so people know where to check at the very least.

 

Glad you could figure it out :)


Reply