24

Hi i'm trying to add in app purchases to my app i have set up my in app purchases on the developer console which are set to active i have then queried them which yesterday was working perfectly i retrieved all the details but today its coming back as null. the only thing that has changed is that i had to uninstall the app and re-run it. I have checked my skus both in the app and on the developer console which match exactly when i run IabHelper start setup i get a result of ok. And then i call IabHelper.QueryInventoryFinishedListener and that results back as being ok but when i try access anything from the inventory it comes back as null. does anyone know why? or if i'm doing some wrong in my code?

in my on Create();

mHelper = new IabHelper(this, base64EncodedPublicKey);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
               public void onIabSetupFinished(IabResult result) {
                  if (!result.isSuccess()) {
                     // Oh noes, there was a problem.
                     Log.v("Menu", "Problem setting up In-app Billing: " + result);
                  }            
                     // Hooray, IAB is fully set up!  
                  Log.v("Menu", "INAPP BILLING SETUP COMPLETE: " + result);
                  ArrayList<String> skuList = new ArrayList<String> ();
                    skuList.add("myapp.consumable.inapppurchase_id_1");
                    skuList.add("myapp.consumable.inapppurchase_id_2");
                    skuList.add("myapp.consumable.inapppurchase_id_3");
                    skuList.add("myapp.permanant.inapppurchase_id_6");
                    skuArray = new JSONArray(skuList);

                    mHelper.queryInventoryAsync(true, skuList, mQueryFinishedListener);

               }
        });

Then i heres my code for the QueryListener

IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
       public void onQueryInventoryFinished(IabResult result, Inventory inventory)   
       {
          if (result.isFailure()) {
              Log.v("Menu", "RESULT FALIURE");
             return;
           }

      Log.v("Menu", "this +" + skuArray);
      Log.v("Menu", "Inventory +" + inventory);
      for(int i = 0; i < skuArray.length(); i++){
          try {
             String SKU = skuArray.getString(i);

             if(inventory.getSkuDetails(SKU) != null){
                 Log.v("Menu", "SKU = " + SKU);
                 Log.v("Menu", "SKU" + SKU + "= " + inventory.getSkuDetails(SKU));

                 updateProductData("price",inventory.getSkuDetails(SKU).getPrice(),i);
                 updateProductData("id",inventory.getSkuDetails(SKU).getSku(),i);


             }else{
                 Log.v("Menu", "SKU RETURNED NULL" + SKU); 
             }



        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


      }

   }
}; 
Luke Batley
  • 2,384
  • 10
  • 44
  • 76
  • Hi Luke. I am also today experiencing issues in getting a list of Sku details from the inventory. I am also using the same IabHelper library you are using. I have too put a question up regarding this. While I do believe in coincidences, I am also wondering if there is a larger problem here as I have not altered my code since it was working. I wonder if we can get confirmation of other people having issues incase we are both trying to fix a problem that does not lie on our side of the fence. – Richard Lewin May 28 '14 at 14:55
  • @RichardLewin i think it could well be something on Googles side it sounds like your having the exact same issue. Iwas just so confused as it was working last night but today its not. – Luke Batley May 28 '14 at 15:01
  • Tell me about it. I was about to start to pull my hair out before I saw your post. While I still feel like pulling it out (due to many deadlines and hours spent getting nowhere) at least the answer might be something out of my hands. I'll let you know if/when it starts working again or I find my issue (if it isn't at Google's end). For you reference my post is at: http://stackoverflow.com/questions/23914116/android-iabv3-getskudetails-not-returning-sku-details – Richard Lewin May 28 '14 at 15:04
  • Same here, yesterday it was working but today it isn't. There was no change in the code and I guess this could be a problem from Google's side, but so far I haven't found any information regarding to this issue – Julian Mancera May 28 '14 at 15:23
  • @JulianMancera I have also been searching with no success. – Richard Lewin May 28 '14 at 16:03

2 Answers2

27

Ok i spoke to Google about this issue. And they say they have made changes which requires the apk to be published before adding in app purchases they recommend uploading the apk to alpha testing channel and published (not in draft mode).

Ill give it a try and feed back if it works

Luke Batley
  • 2,384
  • 10
  • 44
  • 76
  • 1
    Many thanks for finding this out. Lets hope that it turns out to be successful. – Richard Lewin May 29 '14 at 15:52
  • 1
    And if it's published to alpha testing channel, you'll need to use real money for testing purchases, I guess. Anyway, this sucks for Google to change this and not say anything. There must be another solution. – Adrian Ancuta May 30 '14 at 11:55
  • @AdrianAncuta You can add testing accounts by specifying email addresses in the developer console. Testing accounts won't have to pay real money for purchases when the game is published in an alpha channel (at least this is how it works for me). – Alex Lockwood Jul 05 '14 at 00:27
  • 3
    @LukeBatley so I need to publish the app for real? No way to test in-app-billing while the app is in beta and not published? In the developer console my beta app still says it's a draft?!? – Georg Feb 10 '15 at 18:02
  • Is it possible to add just tester email accounts instead of Google Groups? – Can Uludağ Jun 04 '15 at 10:03
  • Hey guys I published my app on the alpha channel and didnt work yet :( Could you check my question ? http://stackoverflow.com/questions/41144227/googles-iap-getskudetails-method-returning-null – salih Dec 15 '16 at 08:46
  • So, to be clear, the app must be published in the Alpha, Beta or Production channel and not the Internal test channel? – Spikatrix Sep 01 '18 at 14:46
  • @salih Please delete your comment as you've deleted your question – Spikatrix Sep 01 '18 at 14:46
4

After I published my alpha apk to google play the billing started to work again.

Paintoshi
  • 816
  • 10
  • 12