question

Surver avatar image
Surver asked

button clicker sample web app not finding amazon.sdktester.json file

I'm running VS 2013 Express and have created a project to test the button clicker demo on localhost on PC. When I run the project & click any of the 4 buttons it gives me the "Running in test mode" alert (so far so good), but then can't find the amazon.sdktester.json file (returns null reference error) despite it residing in the same directory as the page I'm running. I'm also having same problem when running the web app on my android 4.2, even though the json file resides in the root sdcard folder as recommended. I'm using v1 (" https://resources.amazonwebapps.com/v1/latest/Amazon-Web-App-API-tester.min.js") & have installed the AmazonSDKtester.apk from the same root folder (& have uninstalled the newer Test App as recommended). I want to get the button clicker sample app running first before venturing further. Any clues as to why the json file is not being found either on localhost or android ? Any help appreciated.
web apps
10 |5000

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

robin avatar image
robin answered
Hello Bruce and welcome, I too had this same issue a year ago when forming the decision as to whether or not go the Web App route. While I'm primarily a Dot.Net C# web services developer, I also choose the Visual Studio editing environment for development. Although it isn't specified and this is your first post, my guess is that you too are more of a developer in the Windows environment. This for me was the biggest obstacle to overcome. While I had seasoned skills in development and deployment on the Windows platform, the same tricks and time savers that I learned there, only somewhat apply here. Unlearning years of fine tuning was the key and success in making these samples function. Simply put, an Android device functions differently than a Windows device. I struggled with the IAP v1.3 examples but found the consumables more easily to get running. If you haven't re-read the detail [1] the 2nd pp and the diagram gave me the insight. Deploying the web page to a remote server, then launching in the Amazon Web App tester allows the .json file to be read. [6] See: 'Posted: Oct 15, 2013 12:54 AM in response to:' Is the required .js file 'Amazon-Web-App-API-tester.min.js' *actually* being pulled onto your device an is the the external call in the correct place. [2] Although it isn't specified, my guess is that double checking was performed prior to creating this post. Since I toyed with this, there have been several OS updates for my device KF HD7, as well as the testers. Double checking those would be prudent. As a suggestion read carefully the Amazon online docs. The answers are there, although maybe no where one would expect. Traversing my posts may provide some help. If these suggestions are still leaving one if fits, the following will help the next Amazonian staff member that may respond. This will save several days time them making the request and the needed info response. * Which Kindle device are you running for Android 4.2 (or competitor product) * What system version is currently sync'd Kindle - Settings >> Device >> About * Verify IAP v1.3 vs v2.0 see the web for subtle differences [3][4] * What relative folder location on the device? I used ES3 to navigate This may help in your IAP Web App pursuit direction. After a year of trial and error and update fun, I abandoned the Web App flavor in favor of a hybrid approach for what I am attempting to accomplish. [5] As presented in 2013 to early 2014, there are a few subtle hindrances for certain tasks to perform. This is not the case for all Web Apps. If you are at all curious, you'll find my discovery over reading all my posts that start back in Sept 2013. An incredible and extremely valuable learning experience. My apologies if my recollection of how the Web App IAP examples function, is now different with the new SDK provided. Happy Coding and keep us posted on your progress . . . Robin IAP docs [1] https://developer.amazon.com/appsandservices/solutions/platforms/webapps/docs/testing-iap.html SDK Tester Environments - amzn_wa.enableApiTester(amzn_wa_tester) [2] https://developer.amazon.com/appsandservices/solutions/platforms/webapps/docs/testing-iap.html#Creating the JSON Data File IAP v2.0 subtle differences [3] https://forums.developer.amazon.com/forums/message.jspa?messageID=12182#12182 [4] https://forums.developer.amazon.com/forums/thread.jspa?threadID=3817&tstart=0 Launching into Silk [5] http://forums.developer.amazon.com/forums/thread.jspa?threadID=2857&tstart=0 Json file reference - relative path [6] https://forums.developer.amazon.com/forums/thread.jspa?threadID=1557&tstart=0 Json file reference Re: Kindle Fire HD7 - File System Insight needed navigating the Kindle Fire HD7 Posted: Oct 15, 2013 12:54 AM in response to: robin
10 |5000

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

Surver avatar image
Surver answered
many thanks Robin for your very detailed response - It'll take a while to go through your response so I'll keep u posted on progress. Just FYI, in the 2nd part of my question I'm running Android 4.2 on a Samsung Galaxy Express phone & did publish the button clicker webapp to a remote server & ran it via the Amazon Web App tester (via input of the URL). A check of the webhost cPanel file manager shows that the .json file is in the same folder as the button clicker .aspx web page - but still didn't find (the SKU's in) the .json file. I even copied the .json file over to the 'Scripts' folder (so it is in same folder as the buttonclicker.js file) but to no avail. regards Bruce
10 |5000

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

robin avatar image
robin answered
Bruce, I know there is much to digest here, but the 'Ah-Ha' light will burn brightly soon. From your last response I believe with reasonable certainty that the tid bit of detail will be uncovered after revisiting link [6] from the previous post. It took me some time to grasp how the split architecture [1] of the Kindle device line works, and understanding that gave me the clue to how the handshaking of IAP functions and where the Web App Tester requires it's init file. Although I'm not sure if the docs were improved for IAP v2 SDK .zip d/l, I was not able to locate a specific instruction on setup for non Kindle devices. Should my assumption that, the non Kindle devices behave the same, be incorrect, it appears your next step may be to start with a Foster's (we call 'em oil cans) and patiently wait for confirmation from an Amazonian staff response. As I continue to wait for a hybrid app store submission response, I'll continue to monitor this thread over the weekend . . . Robin 5 min video on the split architecture - page bottom [1] http://amazonsilk.wordpress.com/ See: Introducing Amazon Silk SEPTEMBER 28, 2011
10 |5000

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

Surver avatar image
Surver answered
Hi Robin, finally some progress in running button clicker API on both localhost & on web server - but not yet working on Android's Amazon Web App Tester - more on that later. I refer here to localhost on my PC (all development is using asp.net 4.5.1 via Visual Studio Express 2013): In my previous posts I thought that the button clicker sample app couldn't find the amazon.sdktester.json file with all the sku item data in it. This was PROBLEM #1: it could FIND the .json file but it couldn't OPEN it because the .json file extension was unknown/un-associated. Solution #1: I put the following code in the web.config file and voila! . . . it can now FIND & OPEN the amazon.sdktester.json file. This was PROBLEM #2: When running the app in browser, still couldn't see the Amazon IAP Dialog box (the Buy button etc). Solution #2: In the buttonclicker.js file I had to add an event argument to each of the 4 buttons' onclick event: eg. $("#theButton").click(function() { buttonPressed(event); }); Then prevent the default event in the associated function: function buttonPressed(event) { event.preventDefault(); etc . . . .} What was happening was the button postback was refreshing the page & wiping out the displayed dialog. So now I could actually BUY a button click ! This was PROBLEM #3: In the Amazon IAP Dialog box (the Buy button etc), I couldn't see the "smallIconUrl" image ! Solution #3: After much experimenting in both localhost & on web server I ended up putting in an absolute url (eg. " http://www.whatever.com/Images/image1.png") rather than a relative URL for the images to appear in localhost, in PC webpage & in Android webpage via default browser. Now to my Samsung Galaxy Express phone using Android's Amazon Web App Tester running the same PC webpage referred to above (the one that was working OK), I still have issues: Firstly, it does find & get the item data from the amazon.sdktester.json file OK. I checked that using . . . : HTML: getMockTest
Javascript: function getMockTest(event) { event.preventDefault(); var mockRed = amzn_wa_tester.getMockItemData("sample.redbutton"); document.getElementById('div1').innerHTML = JSON.stringify(mockRed); } . . . and the sample.redbutton item data is displayed in div1 as expected. But I still can't get the Amazon IAP Dialog box (the Buy button etc), to display ! When I click any of the 4 original buttons it just does nothing. I have removed the event.preventDefault(); code but that doesn't help either. So I'm still at a loss as to what the problem is when running the buttonclicker app on my Samsung Galaxy Express phone via the Amazon Web App Tester !! Any clues appreciated !! Bruce PS: I've still got the SDKtester app (for v1) installed (NOT the newer Test App for v2).
10 |5000

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

Surver avatar image
Surver answered
sorry for the crappy text - it wouldn't allow me to edit the post with line breaks. will try posting again.
10 |5000

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

Surver avatar image
Surver answered
Hi Robin, finally some progress in running button clicker API on both localhost & on web server - but not yet working on Android's Amazon Web App Tester - more on that later. I refer here to localhost on my PC (all development is using asp.net 4.5.1 via Visual Studio Express 2013): In my previous posts I thought that the button clicker sample app couldn't find the amazon.sdktester.json file with all the sku item data in it. This was PROBLEM #1: it could FIND the .json file but it couldn't OPEN it because the .json file extension was unknown/un-associated. Solution #1: I put the following code in the web.config file and voila! . . . it can now FIND & OPEN the amazon.sdktester.json file. This was PROBLEM #2: When running the app in browser, still couldn't see the Amazon IAP Dialog box (the Buy button etc). Solution #2: In the buttonclicker.js file I had to add an event argument to each of the 4 buttons' onclick event: eg. $("#theButton").click(function() { buttonPressed(event); }); Then prevent the default event in the associated function: function buttonPressed(event) { event.preventDefault(); etc . . . .} What was happening was the button postback was refreshing the page & wiping out the displayed dialog. So now I could actually BUY a button click ! This was PROBLEM #3: In the Amazon IAP Dialog box (the Buy button etc), I couldn't see the "smallIconUrl" image ! Solution #3: After much experimenting in both localhost & on web server I ended up putting in an absolute url (eg. " http://www.whatever.com/Images/image1.png") rather than a relative URL for the images to appear in localhost, in PC webpage & in Android webpage via default browser. Now to my Samsung Galaxy Express phone using Android's Amazon Web App Tester running the same PC webpage referred to above (the one that was working OK), I still have issues: Firstly, it does find & get the item data from the amazon.sdktester.json file OK. I checked that using . . . : HTML: getMockTest
Javascript: function getMockTest(event) { event.preventDefault(); var mockRed = amzn_wa_tester.getMockItemData("sample.redbutton"); document.getElementById('div1').innerHTML = JSON.stringify(mockRed); } . . . and the sample.redbutton item data is displayed in div1 as expected. But I still can't get the Amazon IAP Dialog box (the Buy button etc), to display ! When I click any of the 4 original buttons it just does nothing. I have removed the event.preventDefault(); code but that doesn't help either. So I'm still at a loss as to what the problem is when running the buttonclicker app on my Samsung Galaxy Express phone via the Amazon Web App Tester !! Any clues appreaciated !! Bruce PS: I've still got the SDKtester app (for v1) installed (NOT the newer Test App for v2). Message was edited by: Bruce Hammond
10 |5000

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

Surver avatar image
Surver answered
Sorry again, I'll attach a Notepad .txt file instead (has the same text as above only readable) . . .
10 |5000

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

robin avatar image
robin answered
Bruce, re: "But I still can't get the Amazon IAP Dialog box (the Buy button etc), to display !" Do I understand that you are able to click-tap on the grey button and count down from ten to zero, 'Clicks left: 0' but still do not see the interstitial dialog as in Fig 7. ? [1] I had this working back in Nov 2013. Sadly that project, notes and data went to HD heaven with a loud click in the beginning of 2014, so I no longer have the original v1 SDK. That said, the deployed original button clicker files were still present on my host server. Lucked out there, and still functions. Bonus! index.html buttons.css amazon.sdktester.json /js/buttonclicker.js Although you haven't stated your development experience in Javascript, it appears you are well versed in both the Html DOM and Javascript, based on the logical step-by-step approach in attempting a solution. I don't recall having this much a struggle myself, and it not working for you is a bit baffling from this end. Forgive me if some of the following suggestions are overstating the obvious. The indication of formatting issues with the forum post made me think of a possible corrupt .html file, with the CR-LF pair. Sidebar: I've had 100% success rate authoring my text, then cut-n-paste into notepad.exe to rule out possible editor file save issues, using Crtl+A Ctrl+C and Ctrl+V to insert into the forum edit field. Is it possible that with all the editing done so far, the original v1 SDK file is somehow damaged? When I load the .html page in Chrome on the desktop, I see an elongated grey button above three colored buttons, left most red, green, blue, with text 'Clicks left 0' below. This is significantly different than the Amazon online docs. Incidentally, I abandoned IE, too bloated, and gave up launching via VStud in favor of Chrome for the element viewer and debugger that will be needed when stepping through deployed script via ADB. Prefer FF debugger, but had to compromise as Amazon implementation is based on Chromium project, thus the need for Chrome browser. Are you seeing the same thing? e.g. is the Html valid Html and the browser rendering a working page? My guess yes, as is indicated 'When I click any of the 4 original buttons' If not, . . . have you re-validated? [2] If this hasn't been discovered, you will need this missing additional line in the doc head: [3] meta http-equiv="Content-Type" content="text/html; charset=UTF-8" As the layout is simple DOM elements, with the associated CSS file, they should render. For a sanity check, I even commented out the three files loaded from their corresponding CDN servers, and the page loads in Chrome on the desktop, with the four buttons visible. This ruled out any possible offending Javascript, and verified that CSS and Html are correct. sc$$ript src=" https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javas$$cript" sc$$ript sc$$ript src=" https://amazon-web-app-resources.s3.amazonaws.com/v0/latest/Amazon-Web-App-API.min.js" type="text/javasc$$ript" sc$$ript sc$$ript src=" https://amazon-web-app-resources.s3.amazonaws.com/v0/latest/Amazon-Web-App-API-tester.min.js" type="text/javasc$$ript" sc$$ript Removed the commented out lines above, so now the Javascript test. After page load, click-tap on grey button ten times. Does the count reduce to zero? If yes, we know that the three .js files are/should-be loading from both CDNs and the single .js file from the relative location at host site. At this point a modal popup dialog appears: 'Buy more clicks?' Ok - Cancel The Amazon .js files should fire off the IAP request and the handshake should occur. 'Ok' of course, will allow the Amazon IAP modal dialog to appear as in Fig 7. If not, does loading each of the above CDN file URIs into the desktop browser as a Url produce renderable Javascript text? Hopefully ruling out network issues. Now on to the Android device. I'm using a KF HD7 ver 1 a gen 2 equiv I verified: /mnt/sdcard/amazon.sdktester.json Using WAT v1 loading the host server URL into the tester allows the web page to be viewed identical to the Chrome desktop version I mentioned above. I remember I had to add a mime type on the host server to allow the .json file to be decoded correctly. I do note the claim using method 'getMockTest(event)' gave the impression the mime type allowed .json d/l Following the steps outlined above allows the IAP buy dialog to appear. I then re-verified by loading the host URL into the Kindle Silk browser with the same positive outcome. Recap: In all three cases, Chrome desktop, WAT tester, and Silk browser the deployed host server content was reachable and thus the client rendered page then had access to the CDN servers to perform the IAP part. As I remember, the sample files worked out of the box. (circa Oct 2013) For your development environment files, do remember the additional amzn_wa.enableApiTester(amzn_wa_tester) [4] Other than the above, I'm near tapped out of ideas. I know that the frustration level can go up when one hears the 'works on my PC' mantra, but back to 'divide and conquer' works(ed) for me. Forgive me should this have been a bit too simplistic. I performed these (re)tests an hour ago to give me the additional sanity check for the v1 SDK sample deployed a year ago. Midnight here - you should be on your second cup of coffee by now and coding away. Fingers crossed this gets you a bit closer to the working solution. Robin Fig. 7: Confirmation Dialog [1] https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/sdk-tester-deprecated https://developer.amazon.com/appsandservices/apis/earn/in-app-purchasing/docs/testing-iap Html validator [2] http://validator.w3.org/ Meta element format [3] http://www.w3.org/WAI/GL/WCAG20/tests/test82.html Using SDK Tester in Desktop Environment [4] https://developer.amazon.com/appsandservices/solutions/platforms/webapps/docs/testing-iap.html#Creating
10 |5000

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

Surver avatar image
Surver answered
thanks again Robin - I've consumed 2 coffees & 2 ales thru the day but still no luck using the Amazon Web App Tester. Would you like to look at www.txword.com/amazon_test/ & see what u think. It works as expected on PC web browser (all 5 main browsers OK). It works as expected on Android default web browser. It works as expected on Android Chrome web browser. But the black purchase dialog will not fire up using the Amazon Web App Tester. I'd be interested to know if it works on your kindle. There are some extra buttons toward bottom of page to play with also. Suggest to try it out on a desktop browser first so you know what to expect (I put an extra alert box in to demonstrate that .json file & UserId are working as expected). Bruce
10 |5000

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

robin avatar image
robin answered
Bruce, re: "I've consumed 2 coffees & 2 ales" . . . . ahhhh, . . . It's clear to me now This worked for me: do { foreach( alesConsumed in aleStock++ ) { var dPcntIntoxication = parseFloat( ((alesConsumed * nQty) / BAC) - wizz ); if( dPcntIntoxication !== parseFloat( objCorrectSolution ) ) nQty++; } } while( !objCorrectSolution ); On initial inspection, I noticed the screen briefly flash during page load. This caused me to peek at the source. After validating and correcting the mis-placed [which wasn't the culprit] .js block, I'm sure just an oops oversight, re: ref /body element, had to dig a bit deeper. When I try to pull amazon.sdktester.json into the browser, nothing is returned. Has the Mime type been correctly set on the server? [answered this following] Yes, but the file may be in the wrong location relative to the launch page. I had to back up a folder relative to page rendered. In fact, when I validated, I observed an additional folder returned appended, after validation. I believe your struggles to be either a relative path issue or related to the hidden viewstate content. I even tried removing the viewstate content and the form elements along with correcting the placement of the closing body element. Deployed to my server. In both cases, IAP isn't active. When loaded into Chrome to debug via adb on my Kindle, the console output shows: "Loaded Legacy resource : https://amazon-web-app-resources.s3.amazonaws.com/v0/latest/Amazon-Web-App-API.min.js Amazon-Web-App-API.min.js:12" "Uncaught WebAppBridgeError: Invalid use of IAP, calling page must be fully secure. Amazon-Web-App-API.min.js:69" Experience here also has taught me not to take the exact verbage literally. Clearly IAP isn't happy and the file location layout is suspect. My staging deployment isn't using anything fancy in the way of SSL. Has the original .html SDK file been deployed and tested without the Dot.Net server side processing? It is possible that the Page.IsPostBack object is creating a new instance on post back therefore, not being recognized as the original page submitted to Amazon IAP. Experience using the Amazon SDK examples have shown them to be simple static pages. I also tried searching stackoverflow, msdn and developer.android for references of using Dot.Net inside an Android WebView, but struck out there. Years ago with older browsers, it was necessary to d/l the Dot.Net runtime. Haven't a clue as to whether Dot.Net is built into Android. Lack of supporting documentation suggests, no. re: "I'd be interested to know if it works on your kindle." No. Not in Android view nor in Amazon WebView. Tap events count down but IAP interstitial dialog is never launched. Sending the invoice for debug services rendered There must be something amiss with the new gen 4 devices as there haven't been many forum responses from the Amazon staff recently. While in week three now waiting my submission approval . . . . zzzzzzz Incidentally, TxWord will make a nice addition to the Amazon app store for Kindle devices. Robin
10 |5000

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