Crash went Initializing Google Play

Hello all. Hopefully someone will be able to help out with this…as I’d like to launch my game soon and this is really the last piece of the puzzle that’s giving me problems.

My game crashes whenever I try to go to the screen with the in-app purchasing…as in it never leaves the screen with my “store” button. However when I comment out the store.init call, it loads up with no problem…but obviously I can’t make any purchases without initializing the store.

I have 3 purchasable items and they are all consumable (game credits basically). So there’s no need for a “restore” as they are all non-managed items.

Here’s the code: (yes, there’s a require(“store”) up at the top of the script that I just didn’t cut and paste here.

local function transactionCallback( event ) print("In transactionCallback", event.transaction.state) local transaction = event.transaction local tstate = event.transaction.state -- --Google does not return a "restored" state when you call store.restore() --You're only going to get "purchased" with Google. This is a work around --to the problem. -- --The assumption here is that any real purchase should happen reasonably --quick while restores will have a transaction date sometime in the past. --5 minutes seems sufficient to separate a purchase from a restore. -- if tstate == "purchased" then print("Transaction succuessful!") native.showAlert("Thank you!", "Your support is greatly appreciated!", {"Okay"}) store.finishTransaction( transaction ) elseif tstate == "restored" then print("Transaction restored (from previous session)") store.finishTransaction( transaction ) elseif tstate == "refunded" then print("User requested a refund -- locking app back") store.finishTransaction( transaction ) elseif tstate == "revoked" then -- Amazon feature print ("The user who has a revoked purchase is", transaction.userId) --Revoke this SKU here: elseif tstate == "cancelled" then print("User cancelled transaction") store.finishTransaction( transaction ) elseif tstate == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) store.finishTransaction( transaction ) else print("unknown event") store.finishTransaction( transaction ) end print("done with store business for now") end if store.availableStores.apple then timer.performWithDelay(1000, function() store.init( "apple", transactionCallback); end) end if store.availableStores.google then timer.performWithDelay( 1000, function() store.init( "google", transactionCallback ); end ) end

The base code is straight out of the in-app purchase tutorial on the Corona site…and I’m not even trying to make purchases yet…since I can’t even get to the screen.

Basically…if I comment out the last section that inits the store…the screen at least loads properly.

Thanks,

Todd

Anything in your console log?

I’m not sure how to view that on the device.

This tutorial should get you started…

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Rob

Thank you very much I’ll look into it. Hopefully that will narrow things down.

Ok. Headed in the right direction (I hope). I’m getting the following error:

attempt to index field ‘availableStores’ (a nil value)

I was hoping for a typo in that field name…but no such luck, so still a little stuck.

Yeah, something’s up with my required “store”. I took the “availableStores” call out of the equation and just forces an store.init call and it still said ‘init’ was a nil value. 

It’s like the require(“store”) isn’t actually returning anything.

What is in your build.settings?

Do you happen to have a file called store.lua in with your main.lua?

Rob

…you know that awesome feeling when you’ve been stuck on something for so long…and then you realize it’s really something super stupid that caused it. Yeah, just had that feeling.

Yes…for some reason I had a store.lua file which I’m not even using in my project. 

Thank you so much for clearing that up. I’m thinking that’s going to have some effect on my success.

Thanks again,

Todd

Simple things are pretty much easy to overlook.

Let the launch commence. Six days and counting.

Thanks again,

Todd

Anything in your console log?

I’m not sure how to view that on the device.

This tutorial should get you started…

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Rob

Thank you very much I’ll look into it. Hopefully that will narrow things down.

Ok. Headed in the right direction (I hope). I’m getting the following error:

attempt to index field ‘availableStores’ (a nil value)

I was hoping for a typo in that field name…but no such luck, so still a little stuck.

Yeah, something’s up with my required “store”. I took the “availableStores” call out of the equation and just forces an store.init call and it still said ‘init’ was a nil value. 

It’s like the require(“store”) isn’t actually returning anything.

What is in your build.settings?

Do you happen to have a file called store.lua in with your main.lua?

Rob

…you know that awesome feeling when you’ve been stuck on something for so long…and then you realize it’s really something super stupid that caused it. Yeah, just had that feeling.

Yes…for some reason I had a store.lua file which I’m not even using in my project. 

Thank you so much for clearing that up. I’m thinking that’s going to have some effect on my success.

Thanks again,

Todd

Simple things are pretty much easy to overlook.