Android inapp billing responseList is empty

守給你的承諾、 提交于 2019-12-05 10:25:06

问题


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.


回答1:


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.




回答2:


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.




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



来源:https://stackoverflow.com/questions/24835180/android-inapp-billing-responselist-is-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!