Fix Amazon purchase tracking setup #1860
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Fixes crash
"java.lang.IllegalArgumentException: Expected receiver of type com.amazon.device.iap.internal.d, but got kotlin.Unit"
and update to allow using appstorev3.0.4
.Details
Motivation
We have many reports of this crash and I was able to reproduce after adding
v3.0.3
of the Amazon AppStore SDK.Additionally,
v3.0.4
of the Amazon AppStore SDK released in March 2023 changed the name of an internal method we rely on, so update to handle this version. We had no reports of this crashing so no one seems to be using this version so far.Scope
listenerHandlerObject
in the startup code for tracking Amazon purchases, and this is the object that got a type ofkotlin.Unit
. The reason is because of the way we were setting it via shorthand. However, let's not use this shorthand since it is easy to make this mistake if we add code in the future.PurchasingListener
when it can be optional, so cast toPurchasingListener?
instead or else we will receive a different NPE crash.I tested on player model, and see it can be nullable. The casting worked differently with Java so we did not encounter this crash.
There is no change to apps not using Amazon AppStore, as we return early and don't go down these lines of code.
An internal method of the appstore SDK was renamed in v3.0.4, and we are now compatible with this version.
Testing
Unit testing
None
Manual testing
Tested on Android emulator API 33
'com.amazon.device:amazon-appstore-sdk:3.0.3'
to Demo App'com.amazon.device:amazon-appstore-sdk:3.0.4'
to Demo App and see there is a crashAffected code checklist
Checklist
Overview
Testing
Final pass
This change is