Android inapp billing responseList is empty
Asked Answered
G

4

29

I have defined some in app products in my app. I've uploaded the apk to the Google Play and added the inapp purchase products on the Google play.

I've got my ServiceConnection defined as followed:

ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mService = IInAppBillingService.Stub.asInterface(service);
            connect();
        }
    };

The onServiceConnected function is called, the bindService returns true.

Next is the connect function.

public void connect() {
        new Thread(new Runnable() {
            public void run() {
                try {

                    // Purchase type is "inapp", as required by  API v3
                    Bundle skuDetails = mService.getSkuDetails(3, PACKET, "inapp", querySkus);

                    }

                    int response = skuDetails.getInt("RESPONSE_CODE");

                    Log.e("IAP connect", response + "");


                    if (response == 0) {
                        ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
                        Log.e("size list", responseList.size()+"");
                        ...
                      }
                    }
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }).start();
}

PACKET here is set to the getPackageName(). The response code is 0 but the Log prints that the size of the list is 0. I have no idea why the list is empty, as I have entered 5 items in total to the Google Play and each of them are active. I have waited 2 days now and tested with three devices, but still no items get through.

I pretty much tried everything I can think of so any suggestions are welcome.

Gospodin answered 18/7, 2014 at 23:26 Comment(0)
C
50

You need to publish your application to Beta/Alpha to access inapp billing functionality. It has recenty changed, but they did not announce it:)

http://developer.android.com/google/play/billing/billing_testing.html#draft_apps

It is worth to mention that you don't have to upload every new build to be able to test it. Just use the same versionCode and versionName, and it will work if the app is published.

Canula answered 21/7, 2014 at 11:1 Comment(15)
That's odd. In another project which runs almost the exact same code, most notably also running Version 3, it uses unmanaged products fine.Gospodin
It reads indeed "Unmanaged products behave differently if you are using in-app billing v3 rather than in-app billing v2. If you are using in-app billing v3, Unmanaged products are treated as Managed products and will need to be explicitly consumed. Learn more" However, I have not purchased anything yet, and I do run a (redundant) loop that consumes the purchases.Gospodin
Well, maybe you are right. Then my only idea is that your application is not published. Have you published it to (Beta/Alpha) or is it in Draft?Canula
I am going to delete all my inapp purchases and select the managed product type. I hope it works. My app is currently in draftGospodin
Do not delete them. The problem is that your app is in Draft. It has recently changed, you need to publish it to access billing info.Canula
Shit I just read it now... after I deleted my products. Well this was a hard lesson for me. Thanks for your help! I can give the bounty in 22 hours, so you'll have to wait for it :)Gospodin
Be aware of the export/import functionality. You could export them, manually edit the type with a text editor, and reimport them. However I'm not sure whether it works for unmanaged items also.Canula
The list is empty, so I can no longer export them. Do you know a way to 'undelete' the product ids? I cannot add them -> "This Product ID has already been used and deleted. It cannot be reused."Gospodin
I guess you are out of luck. You have to create a new app to use those skus again. Once you publish it, it will stay there.Canula
I see, I guess i'll use new product IDs then :( Thanks!Gospodin
Gooey, I have same problem. the status of application is Draft but i have uploaded apk in alpha testing section. this is what in google documentation. how did you manage to solve the problem ? plz helpRemittance
For those whose app is already published, you still have to upload another release (in beta or alpha or internal tester) for subscriptions to work.Gearhart
developer.android.com/google/play/billing/test says "License testers can bypass this check, meaning you can sideload apps for testing, even for apps using debug builds with debug signatures without the need to upload to the new version of your app." Some say you do not need to publish the app to test in app purchase. What's the point of getting Google to review your unfinished app just to test in app purchase?Enface
you do have to publish your app - as my published app started to return the skydetailslist. It's a real beauty. You need to complete in App Store information in GooglePLay and pass Google's review just to test out in-app purchases, which in my opinion is a terrible design as of Sep 9th 2020, but it is how it is.Enface
@Enface How to know if the app has passed the review process in the new developers console? Is there a label somewhere? I get always an empty list response when querying the products. My testers can download already the app from beta and alpha.Akanke
V
27

Your Code looks ok.

Make sure you query the right SKUs. The single items in querySkus must match exactly the id of the in app product.

Second make sure to query the correct type if items. If you configured "in app products" as a car to buy in the developer console, use "inapp" as you did. If you have subscriptions, use "subs" as type of your query against Google Play.

Hope this helps.

Vanzant answered 21/7, 2014 at 10:48 Comment(3)
Yes, I've double checked the ID's of the sku's in both the querySkus list and the Google Play. They are unmanaged products, and all are displayed active.Gospodin
You saved my day. Magister Halderian. Thanks a ton.Materse
I can't upvote this a hundred times but I would! that bit about "subs" vs "inapp" thanks a lot!Fixative
S
3

I had the problem on an old device. Deleting Play Services app data fixed the problem.

So we simply need to get ready for the bad reviews...

Sphery answered 22/7, 2019 at 11:13 Comment(1)
This is good solution for me. I got empty skuDetail on specific product.Underplot
P
0

I had the same problem, the fix was setting my subscription status to "active". After a few minutes it finally worked.

Protestant answered 10/11, 2021 at 10:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.