Gooey
Gooey

Reputation: 4778

Android inapp billing responseList is empty

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.

Upvotes: 29

Views: 14196

Answers (4)

Christian C
Christian C

Reputation: 538

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

Upvotes: 0

Tim Autin
Tim Autin

Reputation: 6165

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...

Upvotes: 3

kupsef
kupsef

Reputation: 3357

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.

Upvotes: 50

Magister Halderian
Magister Halderian

Reputation: 631

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.

Upvotes: 27

Related Questions