No errors with the testing environment. It showed me the price this time which it didn’t before.
Rob
No errors with the testing environment. It showed me the price this time which it didn’t before.
Rob
Wonderful, thank you again Rob. I’ll submit the update now and should be able to tell if it’s fixed within a day or two.
Well I’m still getting reports of crashes with the new version. But whats odd is I’m seeing crashes on all types of Kindle now’s, not just first-gens. I’m not able to replicate on my Kindle Fire HD, it loads and plays just fine. Rob, can I ask another favor and when you have time, could you uninstall and download the current version on Amazon? I’d really appreciate it! Very odd behavior here.
http://www.amazon.com/Barnyard-Games-for-Kids-Free/dp/B0076ANQQC
version 3.2?
Yup.
It crashed after the menu of options showed up. This was what was in the console.
W/dalvikvm( 7808): threadid=8: thread exiting with uncaught exception (group=0x400155a8)
E/AndroidRuntime( 7808): FATAL EXCEPTION: GLThread 9
E/AndroidRuntime( 7808): java.lang.NullPointerException
E/AndroidRuntime( 7808): at java.util.Hashtable.put(Hashtable.java:369)
E/AndroidRuntime( 7808): at plugin.amazon.iap.LuaLoader$1.executeUsing(LuaLoader.java:241)
E/AndroidRuntime( 7808): at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)
E/AndroidRuntime( 7808): at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)
E/AndroidRuntime( 7808): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:300)
E/AndroidRuntime( 7808): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)
E/AndroidRuntime( 7808): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)
E/AndroidRuntime( 7808): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)
W/ActivityManager( 1404): Force finishing activity com.kevinbradford.games.barnyardgamesfree/com.ansca.corona.CoronaActivity
The plugin is still getting a null pointer exception. What activity is going on with the store at that point?
Put in some print statements around your store actions. In the transaction handler, put in the line:
print( json.prettify( event ) )
near the top of the function (you will have to require the json library as well). We need some intel on what values you’re passing to functions and what you’re getting back.
Rob
So same behavior as before when you download from the store. It’s interesting that when you side loaded the APK it worked fine, but downloaded from the store breaks everything. Sounds like I’d have to put back in print statements into the code and go through the Amazon process again in order to really debug it.
I have this at the end of my enterScene method, which must be causing all the problems. Amazon wants us to call a store.restore to check if a new install had previously purchased, and I figure enterScene would be the best place to do it.
-- attempt amazon restore if it's their first time loading if deviceBuild == "kindle" and fullVersion == false then if tonumber(fileHandler.getValue( "attemptedAmzRestore", 0 )) == 0 then -- do once --print("DEBUG: checking for amazon restore") fileHandler.setValue( "attemptedAmzRestore", 1 ) store.restore() end end
Here’s the rest of my store code, it’s a bit disjointed but it has been working for years on Amazon/Apple/Google so I know it’s solid.
local store = require("store") if (system.getInfo("targetAppStore") == "amazon") or (deviceBuild == "kindle" and system.getInfo("environment") == "simulator") then store = require "plugin.amazon.iap" end
transactionCallback = function ( event ) if event ~= nil then if event.transaction ~= nil then --print("DEBUG: transaction callback") local transaction = event.transaction if transaction.state == "purchased" then --print("Transaction succuessful!") unlockAll() elseif transaction.state == "restored" then --print("DEBUG: transaction callback - restored") unlockAll() --print("Transaction restored (from previous session)") --print("productIdentifier", transaction.productIdentifier) --print("receipt", transaction.receipt) --print("transactionIdentifier", transaction.identifier) --print("date", transaction.date) --print("originalReceipt", transaction.originalReceipt) --print("originalTransactionIdentifier", transaction.originalIdentifier) --print("originalDate", transaction.originalDate) elseif transaction.state == "cancelled" then --print("User cancelled transaction") elseif transaction.state == "failed" then --print("Transaction failed, type:", transaction.errorType, transaction.errorString) else --print("unknown event") end -- Once we are done with a transaction, call this to tell the store -- we are done with the transaction. -- If you are providing downloadable content, wait to call this until -- after the download completes. store.finishTransaction( transaction ) --print("DEBUG: transaction finish") end end end
--print("DEBUG: store init") store.init( transactionCallback ) if (deviceBuild == "ios" or deviceBuild == "kindle") and ( store.canLoadProducts ) then --print("DEBUG: load products 1") store.loadProducts( listOfProducts, productCallback ) end
local function productCallback( event ) print( "Showing valid products:", #event.products ) for i = 1,#event.products do print( event.products[i].title ) print( event.products[i].description ) print( event.products[i].price ) print( event.products[i].localizedPrice ) print( event.products[i].priceLocale ) print( event.products[i].productIdentifier ) price = "Price: " .. tostring(event.products[i].localizedPrice) end -- print( "Showing invalid products:", #event.invalidProducts ) -- for i = 1,#event.invalidProducts do -- print( event.invalidProducts[i] ) -- end end
Another suggestion is to put the restore function on a button. This is how Apple insists that you handle this. If store.restore() is the culprit and it could be a problem is there is nothing to restore, you could at least get people into the game and playing it. You only need to restore if someone deletes and reinstalls the app later. Since this isn’t a common thing, doing a restore at the beginning seems a bit
brute force.
In the mean time I’ll loop in the engineer who did the plugin and see if he has any thoughts. We may need a bug report at some point, but it will be tough since it’s a live server issue.
Rob
Also can you put prints in and around your code to fetch the prices and items and make sure you’re not crashing there?
That’s how I’ve had it implemented for years (a button for restore), but when migrating to IAP v2 on Amazon it said they required the app to automatically check for purchases that may have been bought previously. So I added this snippet of code, which worked fine in simulator and on device testing environment. But seems to break horribly in production.
And of course now I cannot find this reference in any of Amazon’s documentation about IAP v2… sigh. I’ll remove this snippet, test, and resubmit. Will keep you updated!
I showed the error to the engineer who wrote the plugin and he was able to find the cause. New plugin binaries have been pushed to the server. It may take a few minutes for them to sync up. But try building now and see if the error is eliminated.
Rob
Would I need to download a new daily build? Also do you know more in detail what is broken? I already have a new binary about to go live on Amazon that simply removed the restore on load code.
Hey Rob, new version 3.3 is out. Would love for you to download and test when you have a moment.
Still crashed:
I/Corona ( 9217): DEBUG: enter scene 1
I/Corona ( 9217): DEBUG: enter scene 2
I/Corona ( 9217): DEBUG: enter scene 3
I/Corona ( 9217): DEBUG: enter scene 4
W/dalvikvm( 9217): threadid=8: thread exiting with uncaught exception (group=0x400155a8)
E/AndroidRuntime( 9217): FATAL EXCEPTION: GLThread 9
E/AndroidRuntime( 9217): java.lang.NullPointerException
E/AndroidRuntime( 9217): at java.util.Hashtable.put(Hashtable.java:369)
E/AndroidRuntime( 9217): at plugin.amazon.iap.LuaLoader$1.executeUsing(LuaLoader.java:241)
E/AndroidRuntime( 9217): at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)
E/AndroidRuntime( 9217): at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)
E/AndroidRuntime( 9217): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:300)
E/AndroidRuntime( 9217): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)
E/AndroidRuntime( 9217): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)
E/AndroidRuntime( 9217): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)
W/ActivityManager( 1404): Force finishing activity com.kevinbradford.games.barnyardgamesfree/com.ansca.corona.CoronaActivity
I’ll ping the engineer again.
Rob
This is not with the new fix he implemented. This was a build done before. Can I just rebuild with my current public release, or do I need to download a daily build?
You know what’s interesting, is I’m seeing 0 crash reports for version 3.3 on Amazon’s dashboard. Usually I’d have 20-30 by now today. You sure you downloaded the new version 3.3 for testing?
You shouldn’t need to change your build. Plugins update independently. You may have not gotten the new one. The error I got was identical to what he fixed.
Rob
Okay, v3.4 is now live and it includes the plugin fix. Please test it out when you get a chance. Thanks Rob for all the help!
It did not crash!
Awesome! Whatever your engineer did fixed the problem. Thanks for all the help Rob, really appreciate it!