Skip to main content
Answer

There is no singleton instance. Make sure you configure Purchases before trying to get the default instance.

  • November 30, 2021
  • 2 replies
  • 5335 views

Forum|alt.badge.img+5

Hello,

I have user crashes related to configuring Purchases.  However, when i have experienced this crash, it is when i am trying to close the app.  I have a single exit point and use:

startActivity(intent);finish();before moving to a new intent.  My exit looks like the following
Thread.currentThread().interrupt();finish();System.exit(0);finish();

Any thoughts?

Best answer by cody

Hey @Dunwiddie!

It looks like you’re trying to access Purchases at some point before it has been configured, or after it’s been destroyed. I’d recommend checking isConfigured before trying to access it: https://github.com/RevenueCat/purchases-android/blob/6a3901a74ae2a39313e8849e4660bc883d6fde61/purchases/src/main/kotlin/com/revenuecat/purchases/Purchases.kt#L1806

This post has been closed for comments

2 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • Answer
  • December 10, 2021

Hey @Dunwiddie!

It looks like you’re trying to access Purchases at some point before it has been configured, or after it’s been destroyed. I’d recommend checking isConfigured before trying to access it: https://github.com/RevenueCat/purchases-android/blob/6a3901a74ae2a39313e8849e4660bc883d6fde61/purchases/src/main/kotlin/com/revenuecat/purchases/Purchases.kt#L1806


Forum|alt.badge.img+5
  • Author
  • Active Member
  • February 25, 2022

Hi Cody,

Thanks for the info.  I tried to follow the GitHub link and translate from Kotlin to Java.  I thought i fixed the issue, but have started getting the same crash again.  Here’s the code that i thought fixed it …

I have attached a screenshot of the code that i thought would fix it

if (Purchases.getSharedInstance() != null )

Thoughts?

Thanks for your help