MonkeyStore - Store unavailable = RuntimeError!?
Monkey Forums/Monkey Bug Reports/MonkeyStore - Store unavailable = RuntimeError!?
| ||
In Android (maybe others) if the store is unavailable, Monkey generates a RunTimeError which causes the Game to crash with: "Unfortunately, xxxx has stopped". Monkey generates the RunTimeError in monkeystore.monkey: If _state<0 Error "Store unavailable" If _state<>0 Error "Store already open" |
| ||
I've changed the code to: (Basically everywhere you had an Error I changed it to a Print and return) This stops the crashing... but is it right?? I was testing having my device Wi-Fi off and loading up my game, then I added code to try to re-connect to the store when Wi-Fi has been turned back on but it doesn't seem to work... |
| ||
Stub the Returns, that stops the store opening even if Wi-Fi is working :/ |
| ||
Nice finding, I stumbled across this as well but don't have a solution yet... |
| ||
The runtime error's are sanity checks to make sure you're not calling functions when the store's in the wrong state, eg: you can only call AddProducts before OpenStoreAsync. Currently, if the store fails to open, you shouldn't use the MonkeyStore object any more. You should either create a new one and start again, or I could add something like a 'Reset' to the class. |
| ||
The runtime error's are sanity checks to make sure you're not calling functions when the store's in the wrong state Yeah I thought as much, but for the application just to die when the store is unavailable needs changing. Currently, if the store fails to open, you shouldn't use the MonkeyStore object any more. You should either create a new one and start again Okay, I will try that approach tonight. |
| ||
> Yeah I thought as much, but for the application just to die when the store is unavailable needs changing. How do you mean? As long as you do things in the correct order: 1) Create MonkeyStore object 2) Call AddProducts 3) Call OpenStoreAsync 4) Check MonkeyStore opened OK - if not, don't use it! You should be OK, ie: your app should never crash. Do things in the wrong order and you'll get a runtime error - in which case your code needs fixing. |
| ||
1) Create MonkeyStore object 2) Call AddProducts 3) Call OpenStoreAsync 4) Check MonkeyStore opened - OK go to 4a else Not OK go to 4b 4a) Continue 4b) Recheck 3 or 4 periodically Create a simple store app execute it without internet access, store unavailable, enable internet, as a user I would now expect the store to be available (as long as its not a Google issue)... and since we dont "kill" apps anymore we really need a solution to recheck the store now and again. |
| ||
> Create a simple store app execute it without internet access, store unavailable, enable internet, as a user I would now expect the store to be available (as long as its not a Google issue)... and since we dont "kill" apps anymore we really need a solution to recheck the store now and again. Currently, the only solution for OpenStore failure is for your app to periodically create a new MonkeyStore object and try again. I can potentially 'fix' this by either adding Reset, or perhaps automatically resetting if OpenStore fails, but I would not like to change the runtime errors so they silently fail. If they occur, your apps doing something wrong (well, by my definition anyway) and in the case of IAP this is kind of serious. |
| ||
Actually, try changing line 223 of monkeystore.monkey from _state=-1 to _state=0. This should allow you to call OpenStoreAsync repeatedly until it succeeds, meaning you don't have to create a new MonkeyStore object, AddProducts etc. Will do some more testing but it looks pretty safe to me. |
| ||
your apps doing something wrong (well, by my definition anyway) and in the case of IAP this is kind of serious. I understand what you are saying, but I couldnt find any information how to deal with this situation which could happen quite often. Actually, try changing line 223 of monkeystore.monkey from _state=-1 to _state=0 Will do, thanks Mark. |
| ||
try changing line 223 of monkeystore.monkey from _state=-1 to _state=0. Looks good on my end :) |
| ||
Monkey generates the RunTimeError in monkeystore.monkey: If _state<0 Error "Store unavailable" If _state<>0 Error "Store already open" What about throwing an exception instead quitting the app with RunTimeError? |