Android: App Purchasing Query returns no products (skuDetails)

I am working on my first Android app. I really learned a lot from stack overflow. But I have not yet found a solution to my current problem.

I tried to implement "when buying an application." I have done the following:

1) In the developer console, I downloaded the signed apk in the alpha and beta test. I also added a test user to the account, and for testing I use this account. In addition, I added some "In Applications (Managed)" with active status.

2) As described in http://developer.android.com/training/in-app-billing/index.html I downloaded the required lib field, copied the code from the TrivialDrive sample project and completed all the steps that resulted in:

// called when the app is started
public void setupConnectionToGooglePlay(final Context context) {
    this.context = context;

    mHelper = new IabHelper(context, base64EncodedPublicKey);

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh no, there was a problem. --> no error message shown to
                // the user!
                Toast.makeText(context, "No connection to google:" + result, Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(context, "connection to google:" + result, Toast.LENGTH_LONG).show();
                // If connection is established:
                get List of all in App Purchase products
                getListOfInAppPurchaseProducts();
            }
        }
    });
}

When I execute this part of the code, I get the result that the connection was successfully established. Therefore, the getListOfInAppPurchaseProducts () method is called.

private void getListOfInAppPurchaseProducts() {
    IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
            if (result.isFailure()) {
                // no error message is shown to the user
                Toast.makeText(context, "Query not successful", Toast.LENGTH_LONG).show();
            } else {
                String message = result.getMessage();
                boolean isSuccess = result.isSuccess();
                // no success message is shown to the user
                List<String> skus = inventory.getAllOwnedSkus();
                Map<String,SkuDetails> map = inventory.getSKUMap();
                int size = map.size();

                Toast.makeText(
                        context,
                        "Message: " + message + "Query successful. Mapsize:" + size, Toast.LENGTH_LONG).show(); 

                WMGooglePlayConnection.this.inventory = inventory;

            }
        }
    };

    ArrayList<String> list = new ArrayList<String>();
    list.add("test");
    list.add("test2");
    mHelper.queryInventoryAsync(true, list, mQueryFinishedListener);
}

Unfortunately, the returned inventory does not contain any SKU details (even the request was successful). I checked the following:

  • productIds
  • product identifier status (active)
  • base64EncodedPublicKey

For testing, I used a real device (Samsung ACE 2). I copied the apk file directly to the device (not downloaded from the Google game). Could this be a problem?

How is it possible to get information about SKU with the emulator?

Do you know what I can check?

, - ...

+4
1

. , Google Play Service 4.4 . , .

, Alpha, / .

Google Play Store , .

https://play.google.com/apps/testing/

, .

+2

Source: https://habr.com/ru/post/1542520/


All Articles