Describe the bug
I read #1848 and noticed you suggest to turn off in-app messages as a workaround, but what if we want that feature enabled?
Can you fix it by either adding some stronger preliminary checks before callingBillingClientImpl.showInAppMessages or try/catching it?
Here's a suggestion to be added to BillingWrapper.kt:
val decorView = activity.window?.decorView
if (decorView == null || decorView.windowToken == null) {
debugLog { "Activity is not attached to a window, not showing Google Play in-app message." }
return@withConnectedClient
}
- Environment
- Platform: Android
- SDK version: 9.19.4
- OS version: All
- Android Studio version: Doesn't matter
- How widespread is the issue. Percentage of devices affected: < 0.1%
- Debug logs that reproduce the issue: Unknown
- Steps to reproduce, with a description of expected vs. actual behavior: Unknown
- Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.IBinder android.view.View.getWindowToken()' on a null object reference
at com.android.billingclient.api.BillingClientImpl.showInAppMessages(com.android.billingclient:billing@@8.0.0:7)
at com.revenuecat.purchases.google.BillingWrapper$showInAppMessagesIfNeeded$2$2.invoke(BillingWrapper.kt:845)
at com.revenuecat.purchases.google.BillingWrapper$showInAppMessagesIfNeeded$2$2.invoke(BillingWrapper.kt:832)
at com.revenuecat.purchases.google.BillingWrapper.withConnectedClient(BillingWrapper.kt:880)
at com.revenuecat.purchases.google.BillingWrapper.access$getStackTrace(BillingWrapper.kt:88)
at com.revenuecat.purchases.google.BillingWrapper.access$withConnectedClient(BillingWrapper.kt:88)
at com.revenuecat.purchases.google.BillingWrapper$showInAppMessagesIfNeeded$2.invoke(BillingWrapper.kt:832)
at com.revenuecat.purchases.google.BillingWrapper$showInAppMessagesIfNeeded$2.invoke(BillingWrapper.kt:827)
at com.revenuecat.purchases.google.BillingWrapper.executePendingRequests$lambda$3$lambda$2$lambda$1(BillingWrapper.kt:155)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:243)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:8531)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1064)
Additional context
Add any other context about the problem here.
Describe the bug
I read #1848 and noticed you suggest to turn off in-app messages as a workaround, but what if we want that feature enabled?
Can you fix it by either adding some stronger preliminary checks before calling
BillingClientImpl.showInAppMessagesor try/catching it?Here's a suggestion to be added to BillingWrapper.kt:
Additional context
Add any other context about the problem here.