Skip to content

java.lang.NullPointerException: key must not be null com.revenuecat.purchases.common.caching.DeviceCache.cleanupOldAttributionData(DeviceCache.kt:165) #737

Description

@AntonioCappiello

java.lang.NullPointerException: key must not be null
com.revenuecat.purchases.common.caching.DeviceCache.cleanupOldAttributionData(DeviceCache.kt:165)
com.revenuecat.purchases.identity.IdentityManager.configure(IdentityManager.kt:41)
com.revenuecat.purchases.Purchases.(Purchases.kt:160)
com.revenuecat.purchases.Purchases.(Purchases.kt:94)
com.revenuecat.purchases.PurchasesFactory.createPurchases(PurchasesFactory.kt:88)
com.revenuecat.purchases.Purchases$Companion.configure(Purchases.kt:2065)
com.revenuecat.purchases.Purchases.configure(Purchases.kt:2)

A simple null check should fix this issue, i.e.:

@Synchronized
fun cleanupOldAttributionData() {
    val editor = preferences.edit()
    for (key in preferences.all.keys) {
        if (key != null && key.startsWith(attributionCacheKey)) {
            editor.remove(key)
        }
    }
    editor.apply()
}

Can you please add this to the next release?
I have paying users who cannot open the app anymore because the app crash on startup due to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions