Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

store.purchase crashes with NullPointerException on some Android devices
Started by stanga Sep 01 2016 12:09 AM

4 replies to this topic
in-app purchase iap nullpointerexception store
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

stanga

[GLOBAL: userInfoPane.html]
stanga
  • Contributor

  • 193 posts
  • Corona SDK

Hi, 

 

We have a user that cannot complete a purchase. Whenever the code reaches the line:

store.purchase(productId)

the app crashes with the following exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.get(java.lang.String)' on a null object reference
Java Stack Trace:
plugin.google.iap.v3.util.IabHelper.getResponseCodeFromBundle(IabHelper.java:809)
plugin.google.iap.v3.util.IabHelper.launchPurchaseFlow(IabHelper.java:413)
plugin.google.iap.v3.util.IabHelper.launchPurchaseFlow(IabHelper.java:359)
plugin.google.iap.v3.util.IabHelper.launchPurchaseFlow(IabHelper.java:354)
plugin.google.iap.v3.LuaLoader.purchase(LuaLoader.java:358)
plugin.google.iap.v3.LuaLoader.access$1400(LuaLoader.java:37)
plugin.google.iap.v3.LuaLoader$PurchaseWrapper.invoke(LuaLoader.java:469)
com.ansca.corona.JavaToNativeShim.nativeTouchEvent(Native Method)
com.ansca.corona.JavaToNativeShim.touchEvent(JavaToNativeShim.java:416)
com.ansca.corona.input.RaiseTouchEventTask.executeUsing(RaiseTouchEventTask.java:39)
com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:170)
com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)
com.ansca.corona.Controller.updateRuntimeState(Controller.java:305)
com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)
com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)
com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)

The user is using a Cubot Note S with the Android OS version 5.1.

The app was compiled with the simulator version 2016.2907. 

 

Any help will be greatly appreciated.

Thanks!

 


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,246 posts
  • Enterprise

What is the value of productId?



[TOPIC: post.html]
#3

stanga

[GLOBAL: userInfoPane.html]
stanga
  • Contributor

  • 193 posts
  • Corona SDK

Since the platform is Android, the value of productId is a string representing the produce id in the Google Play store (it works for other Android users)



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,246 posts
  • Enterprise

Sorry, I should have been more clear. I was hoping you would drop a print statement in and verify the value of productId when you get the crash. I was curious what the exact value was at the time of the crash.

 

Rob



[TOPIC: post.html]
#5

stanga

[GLOBAL: userInfoPane.html]
stanga
  • Contributor

  • 193 posts
  • Corona SDK

I don't understand why the actual product id's we're using are relevant for the crash...

It's not a specific product that caused it, but all the products the user tries to purchase.

Our product id's are all in the form of com.host.lower.caps.unique.name

 

I suspect the problem is related to the user's Android OS, since a Bundle object is expected to be initialized and it's null. 




[topic_controls]
[/topic_controls]