question

jonathan avatar image
jonathan asked

Cannot run search tools

I am receiving an error when try to iterate through a SearchResult. I have testing set up and a simple JSON Data File. The error looks like this: [i]I receive the 11-23 10:05:10.735: E/com.amazon.device.associates.o(737): IAP Physical SDK/Sandbox Mode: Error in callListener: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0[/i] My data file looks like this: { "Copy Paper" : { "itemType": "ENTITLED", "price": 10.00, "title": "Test Copy Paper", "description": "8 1/2 x 11 inch, 20lb, white, copy paper.", "smallIconUrl": http://scene7.samsclub.com/is/image/samsclub/0001019900246_B?wid=1500&hei=1500&fmt=jpg&qlt=80 } } Any Pointers? Many Thanks, Jonathan -- public void onSearchResponse(SearchResponse response) TextView textView; ImageView imageView; List products = response.getProducts(); Product product; Log.v("SearchResults","Received Search Response"); //Using the first entry in the search response //set item title, photo, and description if (products!=null){ Log.v("SearchResults","products!=null"); Log.v("SearchResults","products is:"+products); product=products.get(0); if (product!=null){ Log.v("SearchResults","product0!=null"); textView = (TextView)this.findViewById(R.id.title1); textView.setText(product.getTitle()); } else { Log.v("SearchResults","product0 is null:"+products); } } }
iap
10 |5000 characters needed characters left characters exceeded

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

1 Answer

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Jonathan, Thank you for writing to us. It seems that your JSON data is not in correct format. The general format of the JSON file is: { PRODUCT_1:{PRODUCT_1_Description}, PRODUCT_2:{PRODUCT_2_Description}, . . . PRODUCT_n:{PRODUCT_n_Description} } https://developer.amazon.com/sdk/mobile-associates/testing.html#Create%20JSON
10 |5000 characters needed characters left characters exceeded

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