Solved

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

  • 30 November 2021
  • 2 replies
  • 2550 views

Userlevel 1
Badge +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?

icon

Best answer by cody 10 December 2021, 19:16

View original

2 replies

Userlevel 6
Badge +8

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

Userlevel 1
Badge +5

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