question

bartjezzz avatar image
bartjezzz asked

onPurchaseResponse purchaseUpdatesResponse.getUserId is null?

Hi guys, we have been working with IAP on Amazon for a year now. With the latest game we release, we noticed new crashes due to null pointer exceptions in PurchaseUpdatesAsyncTask. Specifically on: protected Boolean doInBackground(final PurchaseUpdatesResponse... params) { final PurchaseUpdatesResponse purchaseUpdatesResponse = params[0]; final SharedPreferences.Editor editor = getSharedPreferencesEditor(); final String userId = baseActivity.getCurrentUser(); //it crashes here if (!purchaseUpdatesResponse.getUserId().equals(userId)) { //we do stuff to handle the purchase } it seems that sometimes purchaseUpdatesResponse is returned null. Track: java.lang.RuntimeException at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.NullPointerException at org.ourgame.lib.PurchaseObserver$PurchaseAsyncTask.doInBackground(PurchaseObserver.java:263) <-- If statement at org.ourgame.lib.PurchaseObserver$PurchaseAsyncTask.doInBackground(PurchaseObserver.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) Any idea what this could be about? What scenario could lead to onPurchaseResponse to be resulting in null? We're talking about a published game, where this happened a few times. Thanks!
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nicole-chen avatar image
nicole-chen answered
Hi, I got the same problem. How can I fix it? Thanks!!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tkoba@amazon avatar image
tkoba@amazon answered
Hi, Could you let us know which IAP SDK version you are seeing this and if there are any additional information like specific occurrence to device types, that will help us investigate on the issue.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nicole-chen avatar image
nicole-chen answered
Hi, I use com.amazon.extensions.AmazonPurchase.ane which is created on 5/4/15, I do not know the version number. One of stack trace: java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.NullPointerException at com.amazon.extensions.android.AmazonPurchaseObserver$PurchaseUpdatesAsyncTask.doInBackground(AmazonPurchaseObserver.java:287) at com.amazon.extensions.android.AmazonPurchaseObserver$PurchaseUpdatesAsyncTask.doInBackground(AmazonPurchaseObserver.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Thanks for your support!!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tkoba@amazon avatar image
tkoba@amazon answered
Thanks for the information. IAPv2 Adobe AIR plugin has been just released. https://developer.amazon.com/public/solutions/platforms/cross-platform/adobe-air Since many improvements have been done for IAPv2, please give it a try to see if it solves your issue.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.