Skip to main content
Solved

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

  • 30 November 2021
  • 2 replies
  • 3912 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

View original
Did this post help you find an answer to your question?

2 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 492 replies
  • 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
  • 10 replies
  • 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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings